This is what I use to lock down a database. This is adapted from info in the Access help. My frmWelcome asks for the password; if they don't respond correctly in 30 seconds, it closes the app. They didn't want real workgroup security in this app.
VERY IMPORTANT!!!! make sure that you have a "secret" clickable button somewhere for you to run the 'Reset' portion, because after it's locked it's really locked.
BTW Any keys that aren't disabled by this, can be re-mapped in AutoKeys to do nothing.
Option Compare Database
Option Explicit
Sub SetStartupProperties()
ChangeProperty "StartupForm", dbText, "frmWelcome"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, False
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, False
ChangeProperty "AllowBreakIntoCode", dbBoolean, False
ChangeProperty "AllowSpecialKeys", dbBoolean, False
ChangeProperty "AllowBypassKey", dbBoolean, False
End Sub
Sub ResetStartupProperties()
ChangeProperty "StartupForm", dbText, ""
ChangeProperty "StartupShowDBWindow", dbBoolean, True
ChangeProperty "StartupShowStatusBar", dbBoolean, True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, True
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowBreakIntoCode", dbBoolean, True
ChangeProperty "AllowSpecialKeys", dbBoolean, True
ChangeProperty "AllowBypassKey", dbBoolean, True
End Sub
Function ChangeProperty(strPropName, varPropType, varPropValue)
Dim dbs As Database, prp As Property
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