Bypass Key Enabled / Disabled

Brogrim
Brogrim used Ask the Experts™
on
I have downloaded some code from MSDN to  Enable / Disable the Startup Key.

My question is

1. how do I enable the bypass when I need to again
2. How is this specific to one mdb file?


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.

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 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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
1.  you call the enable function from the click event procedure of any object.

For example, you might put a label on your main form in place only you know and format it so that is not visible against the background.  

2.  the property 'allowbypasskey' is a property of a database.  So setting the property is only setting it for whichever database is being referenced.
BrogrimInformation Systems Development Manager

Author

Commented:
How do I include a password?
I an assuming you are referring to the Enable function.

After the Const command add ..(use  your own password value)

If inputbox("Enter Password","Enable ByPass Key") = "password"   then
' OK- do nothing
else
   msgbox "Invalid Password"
   exit function
End if

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial