To create a true lock for your application:
1. Create a new form with 2 command buttons and add the following code:
Private Sub Command0_Click()
'************** Alter default settings ******************
Dim db As DAO.Database
Dim pty1 As Property
Dim pty2 As Property
Dim pty3 As Property
Dim pty4 As Property
Dim pty5 As Property
Dim pty6 As Property
Dim pty7 As Property
Dim pty8 As Property
Dim pty9 As Property
On Error GoTo NoShift_Err
Set db = CurrentDb
'*********** Make shure the user isn't bothered ***************
Application.SetOption "Confirm Record Changes", False
Application.SetOption "Confirm Document Deletions", False
Application.SetOption "Confirm Action Queries", False
'******* Disable some features not needed at runtime **********
db.Properties("StartupShowDBWindow").Value = False
db.Properties("AllowFullMenus").Value = False
db.Properties("AllowBreakIntoCode").Value = False
db.Properties("AllowSpecialKeys").Value = False
db.Properties("AllowBypassKey").Value = False
db.Properties("AllowBuiltinToolbars").Value = False
'*********** Set some customized properties ***************
db.Properties("StartupForm").Value = "frmSplash"
db.Properties("AppTitle").Value = "PutAppTitleHere"
db.Properties("AppIcon").Value = "IconFullPathHere"
NoShift_Exit:
Exit Sub
NoShift_Err:
If Err.Number = 3270 Then
Set pty1 = db.CreateProperty("StartupShowDBWindow", dbBoolean, False)
Set pty2 = db.CreateProperty("AllowFullMenus", dbBoolean, False)
Set pty3 = db.CreateProperty("AllowBreakIntoCode", dbBoolean, False)
Set pty4 = db.CreateProperty("AllowSpecialKeys", dbBoolean, False)
Set pty5 = db.CreateProperty("AllowBypassKey", dbBoolean, False)
Set pty6 = db.CreateProperty("AllowBuiltinToolbars", dbBoolean, False)
Set pty7 = db.CreateProperty("StartupForm", dbText, "frmSplash")
Set pty8 = db.CreateProperty("AppTitle", dbText, "PutAppTitleHere")
Set pty9 = db.CreateProperty("AppIcon", dbText, "IconFullPathHere")
db.Properties.Append pty1
db.Properties.Append pty2
db.Properties.Append pty3
db.Properties.Append pty4
db.Properties.Append pty5
db.Properties.Append pty6
db.Properties.Append pty7
db.Properties.Append pty8
db.Properties.Append pty9
Else
MsgBox Err.Description
Resume NoShift_Exit
End If
End Sub
Private Sub Command1_Click()
'************** Restore default settings *****************
Dim db As DAO.Database
Dim pty1 As Property
Dim pty2 As Property
Dim pty3 As Property
Dim pty4 As Property
Dim pty5 As Property
Dim pty6 As Property
Dim pty7 As Property
Dim pty8 As Property
Dim pty9 As Property
On Error GoTo AllowShift_Err
Set db = CurrentDb
Application.SetOption "Confirm Record Changes", True
Application.SetOption "Confirm Document Deletions", True
Application.SetOption "Confirm Action Queries", True
db.Properties("StartupShowDBWindow").Value = True
db.Properties("AllowFullMenus").Value = True
db.Properties("AllowBreakIntoCode").Value = True
db.Properties("AllowSpecialKeys").Value = True
db.Properties("AllowBypassKey").Value = True
db.Properties("AllowBuiltinToolbars").Value = True
db.Properties("StartupForm").Value = "(none)"
db.Properties("AppTitle").Value = "PutAppTitleHere"
db.Properties("AppIcon").Value = "IconFullPathHere"
AllowShift_Exit:
Exit Sub
AllowShift_Err:
If Err.Number = 3270 Then
Set pty1 = db.CreateProperty("StartupShowDBWindow", dbBoolean, True)
Set pty2 = db.CreateProperty("AllowFullMeDas", dbBoolean, True)
Set pty3 = db.CreateProperty("AllowBreakIntoCode", dbBoolean, True)
Set pty4 = db.CreateProperty("AllowSpecialKeys", dbBoolean, True)
Set pty5 = db.CreateProperty("AllowBypassKey", dbBoolean, True)
Set pty6 = db.CreateProperty("AllowBuiltinToolbars", dbBoolean, True)
Set pty7 = db.CreateProperty("StartupForm", dbText, "(none)")
Set pty8 = db.CreateProperty("AppTitle", dbText, "PutAppTitleHere")
Set pty9 = db.CreateProperty("AppIcon", dbText, "IconFullPathHere")
db.Properties.Append pty1
db.Properties.Append pty2
db.Properties.Append pty3
db.Properties.Append pty4
db.Properties.Append pty5
db.Properties.Append pty6
db.Properties.Append pty7
db.Properties.Append pty8
db.Properties.Append pty9
Else
MsgBox Err.Description
Resume AllowShift_Exit
End If
End Sub
2. You can open this form from your application and enable (runtime mode)
or disable (debug mode) the custom settings by clicking the buttons.
3. Exit and reopen database for effect.