Hack #80. Prevent Users from Disabling Your Startup Options

Stop users from being able to hold down the Shift key to get to the database window.

After spending all that time developing your database application and then setting the startup options, the last thing you want is for someone to be able to simply hold down the Shift key during startup and then mess around with your application. This hack explores two different ways to prevent this: disabling the Shift key code for Access databases (MDBs) and disabling the Shift key code for Access Data Projects (ADPs).

Access MDB

With MDB files, the hack works by adding a property called AllowBypassKey to the database object. Setting the property to False disables the Shift key, and changing it back to True enables it again. You need to decide on an event to trigger the value change. It could be when a specific user logs into the database or, as in this code example, when a file named AllowByPass.txt is in the same directory as the database:

 Public Function DetermineByPass( ) If Len(Dir(CurrentProject.Path & "\AllowByPass.txt")) = 0 Then ChangeProperty "AllowBypassKey", DB_BOOLEAN, False, True Else ChangeProperty "AllowBypassKey", DB_BOOLEAN, True, True End If End Function Public Function ChangeProperty(strPrpName As String,_ varPrpType As Variant, _ varPrpValue As Variant, _ bolDDL as Boolean) As Boolean Dim prp As Variant Const conPrpNotFoundError = 3270 On Error GoTo ChangePrp_Err CurrentDb.Properties(strPrpName) = varPrpValue ChangeProperty ...

Get Access Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.