
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.
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
|
Next time you start this database up, you will notice that holding down the shift key no longer bypasses any startup options.
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: