You are on page 1of 3

The startup options that are defined for an Access file determine how the file l ooks and

how the file behaves when you open the file. You can set the startup op tions by using the startup user interface or by using the AutoExec macro. To byp ass 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 enfo rce the startup options that are set for the Access database project, disable th e functionality of the SHIFT key that permits you to bypass the startup options. To do this, set the AllowBypassKey property to False. To set the AllowBypassKey property to False, follow these steps. Steps for an Access database (.mdb or .accdb) 1. Start Access. 2. Create a new module, and then add the following two function s: Function ap_DisableShift() 'This function disable the shift at startup. This act ion 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 success ful. Exit Function errDisableShift: 'The first part of this error routine create s the "AllowByPassKey 'property if it does not exist. If Err = conPropNotFound T hen Set prop = db.CreateProperty("AllowByPassKey", _ dbBoolean, False) db.Proper ties.Append prop Resume Next Else MsgBox "Function 'ap_DisableShift' did not com plete 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. On Error GoTo errEnableShi ft 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 successful Exit Function errEna bleShift: 'The first part of this error routine creates the "AllowByPassKey 'pro perty if it does not exist. If Err = conPropNotFound Then Set prop = db.CreatePr operty("AllowByPassKey", _ dbBoolean, True) db.Properties.Append prop Resume Nex t Else MsgBox "Function 'ap_DisableShift' did not complete successfully." Exit F unction End If End Function 3. In the Visual Basic editor, click Immediate Window on the View menu. 4. If yo u want to disable the SHIFT key, type ap_DisableShift in the Immediate window, a nd then press ENTER. If you want to enable the shift key, type ap_EnableShift in the Immediate window, and then press ENTER.

You might also like