7/02/2012

Disable 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 bypassed and the Database window appears.

How can I disable the Shift key when a user logs in so that the Database window remains hidden?


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.



What you need to do is change the Database Property to False to disable the Shift key. To do this, you need to run the following VBA code:

Sub DisableShiftKey()

Dim db As DAO.Database
Dim prp As DAO.Property

Set db = CurrentDb
db.Properties.Delete "AllowBypassKey"
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, False, 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 disable 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