how the file behaves when you open the file. You can set the startup options by using the
startup user interface or by using the AutoExec macro.
To bypass the startup options that are set for the Access database project, hold down the
SHIFT key while you open the Access database project.
Alternatively, to enforce the startup options that are set for the Access database project,
disable the functionality of the SHIFT key that permits you to bypass the startup options.
To do this, set the AllowBypassKey property to False.
1. Start Access.
2. Create a new module, and then add the following two functions:
Function ap_DisableShift()
'This function disable the shift at startup. This action causes
'the Autoexec macro and Startup properties to always be executed.
Dim db As DAO.Database
Dim prop as DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
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.
Dim db as DAO.Database
Dim prop as DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
'function successful
Exit 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
3. In the Visual Basic editor, click Immediate Window on the View menu.
4. 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.