Preventing Shift-Key ByPass in Access:   Return to List

Function SetBypassKey(rbFlag As Boolean) As Integer
    On Error GoTo SetBypassKey_Error
    ' This function creates a new database property
    ' which can prevent a user from using from using
    ' the shift key to bypass the startup options

    ' The function must be run at least once during development.
    ' Run it from the Debug window
    ' using the appropriate argument:
    ' ?SetBypassKey(True) 'Enables the Shift Key bypass
    ' ?SetBypassKey(False) 'Disables the Shift Key bypass
    ' -------------------------------------------
    Dim db As DAO.Database
    Set db = CurrentDb
    db.Properties!AllowBypassKey = rbFlag

    SetBypassKey_Exit:
        Exit Function

    SetBypassKey_Error:
    If Err = 3270 Then
    ' AllowBybassKey property does not exist
        db.Properties.Append _
            db.CreateProperty("AllowBypassKey", _
            dbBoolean, rbFlag)
        Resume Next
    Else
    ' Some other error
        MsgBox "Unexpected error: " & Error$ & " (" & Err & ")"
        Resume SetBypassKey_Exit
    End If
End Function



Note to Webmaster