7/02/2012

Re-enable the Shift key when logging into a secure database in Access

Question: In Access 2003/XP/2000/97, I've secured a database using the User-Level Security Wizard and I've also hidden the Database window in the Startup Options for the database. However, when a user logs in while holding down the Shift key, the Startup Options are not bypassed and so the Database window will not appear.
How can I re-enable the Shift key when a user logs in so that the Database window becomes visible?
Answer: Within your Access database, there is a Database Property called "AllowBypassKey". By default, your Access database sets this property to True and allows users to use the Shift key functionality when logging into a secured database.



If you are unable to use the Shift key to bypass the Startup Options and display the Database window, the "AllowBypassKey" property has been set to False and you need to change it back to True.
To do this, you need to run the following VBA code:
Sub EnableShiftKey()
    Dim db As DAO.Database
    Dim prp As DAO.Property
    Set db = CurrentDb
    db.Properties.Delete "AllowBypassKey"
    Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, True, True)
    db.Properties.Append prp
    db.Properties.Refresh
    Set prp = Nothing
    Set db = Nothing
End Sub
You only need to run this code once and your database will re-enable the Shift key from that point on - even if the Access database is shutdown and restarted.
Just make sure that when you run the code, you have Administrator privileges to the database.
Tip: You may want to create a button on a form that allows you to enable or disable the Shift key. You can make the button visible to only certain users with the CurrentUser function.

If after trying this example, you receive a "not defined" error on the "Dim db as DAO.Database" declaration, you will need to follow some additional instructions.

No comments:

Post a Comment