See also:
- http://msdn.microsoft.com/en-us/library/bb256564(v=office.12).aspx
- http://support.microsoft.com/kb/826765/en-us
Put this code into a Module of your Access DB.
Public Sub Secure_database()
' this will require that there is a visible form already displayed!!! With CurrentDb .Properties("AllowShortcutMenus") = False .Properties("AllowFullMenus") = False' .Properties("AllowBreakIntoCode") = False .Properties("AllowShortcutMenus") = False .Properties("AllowSpecialKeys") = False .Properties("StartupshowDBWindow") = False End With DoCmd.Save DoCmd.CloseDatabase End Sub
Public Sub UnSecure_database()
With CurrentDb .Properties("AllowShortcutMenus") = True .Properties("AllowFullMenus") = True '.Properties("AllowBreakIntoCode") = True .Properties("AllowShortcutMenus") = True .Properties("AllowSpecialKeys") = True .Properties("StartupshowDBWindow") = True End With DoCmd.Save DoCmd.CloseDatabase
End Sub
Function ap_DisableShift()'This function disable the shift at startup. This action causes'the Autoexec macro and Startup properties to always be executed.
On Error GoTo errDisableShift
Dim db As DAO.Database Dim prop As DAO.Property Const conPropNotFound = 3270 Set db = CurrentDb() 'This next line disables the shift key on startup. db.Properties("AllowByPassKey") = False 'The function is successful.Exit Function
errDisableShift: 'The first part of this error routine creates the "AllowByPassKey 'property if it does not exist. If Err = conPropNotFound Then Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, False) db.Properties.Append prop Resume Next Else MsgBox "Function 'ap_DisableShift' did not complete successfully." Exit Function End If
End Function
Function ap_EnableShift() 'This function enables the SHIFT key at startup. This action causes 'the Autoexec macro and the Startup properties to be bypassed 'if the user holds down the SHIFT key when the user opens the database. 'If you want to disable the SHIFT key, type ' ap_DisableShift in the Immediate window, and then press ENTER. 'If you want to enable the shift key, type ' ap_EnableShift in the Immediate window, and then press ENTER.
On Error GoTo errEnableShift Dim db As DAO.Database Dim prop As DAO.Property Const conPropNotFound = 3270 Set db = CurrentDb() 'This next line of code disables the SHIFT key on startup. db.Properties("AllowByPassKey") = True 'function successfulExit Function
errEnableShift: 'The first part of this error routine creates the "AllowByPassKey 'property if it does not exist. If Err = conPropNotFound Then Set prop = db.CreateProperty("AllowByPassKey", _ dbBoolean, True) db.Properties.Append prop Resume Next Else MsgBox "Function 'ap_DisableShift' did not complete successfully." Exit Function End If
End Function
No comments:
Post a Comment