Disable Shift-Key ByPass

Saturday, October 19, 2002 09:31:56
home

Preface: if you hold down the SHIFT key when loading up a database, any startup options you have are bypassed. If you have a database geared towards an end-user, you may wish to prevent this from happening--say, to prevent them from going to your source data tables.

The steps to bypass this "back door":

  • First off, always do this to a copy of the database; that way, you (the designer) always have a way in
  • Create a new module, with the following code
    Sub SetBypassProperty()
    Const DB_Boolean As Long = 1
        ChangeProperty "AllowBypassKey", DB_Boolean, False
    ' To re-enable shift bypass change the above line to True, hold down CTRL-G and in the ensuing window type
    ' Call SetBypassProperty
    End Sub
    
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
        Dim dbs As Object, prp As Variant
        Const conPropNotFoundError = 3270
    
        Set dbs = CurrentDb
        On Error GoTo Change_Err
        dbs.Properties(strPropName) = varPropValue
        ChangeProperty = True
    
    Change_Bye:
        Exit Function
    
    Change_Err:
        If Err = conPropNotFoundError Then    ' Property not found.
            Set prp = dbs.CreateProperty(strPropName, _
                varPropType, varPropValue)
            dbs.Properties.Append prp
            Resume Next
        Else
            ' Unknown error.
            ChangeProperty = False
            Resume Change_Bye
        End If
    End Function
    
  • Save the module with a meaningful name like mod_Disable_Shift_Key (do not name it "AllowByPassKey")
  • Compile/save the module
  • Open the debug window by typing CTRL-G
  • In the ensuing window that opens, type Call SetBypassProperty
  • Close and save the module

    Next time you start this database up, you will notice that holding down the shift key no longer bypasses any startup options.

    How to Go Back to Allowing ByPass

    It's always smart to keep a backup copy of the database that does not have the shift key disenabled. Nonetheless, if you are able to manipulate your way to the database window and can edit the module, then you can undo the bypass as follows:

  • Open the module in design view
  • Change the line ChangeProperty "AllowBypassKey", DB_Boolean, False to ChangeProperty "AllowBypassKey", DB_Boolean, True.
  • Compile the module
  • Open the debug window (CTRL-G)
  • Type the following line in the ensuing window: Call SetBypassProperty
  • Close & save the module