Disabling the Shift Key at startup

P

Paul G

Got this off the net.

When an Access database is configured to perform actions
at startup, whether through a startup from an AutoExec
macro, users can stop the actions from executing by
holding down the [Shift] key while the database is
opening. To prevent this from happening, you can use VBA
to stop the [Shift] key's ability to skip startup actions.
To do so, you need to set the AllowBypassKey property
equal to False. Unlike the properties you're used to
working with, this property is user-defined, meaning you
need to define the property with code and append it to the
database's Properties collection. The property is
persistent, so it remains in the collection after you
close the database, unless you specifically delete it.

To create a simple procedure to make and set the
AllowBypassKey property, choose Module from the New Object
button menu. Then, enter the following code:

Function PreventBypass() As Boolean
Set prp = CurrentDb.CreateProperty("AllowBypassKey", _
dbBoolean, False, True)
CurrentDb.Properties.Append prp
Set prp = Nothing
End Function

You can run this code to create the AllowBypassKey
property by simply clicking the Go/Continue button (Run
Sub/UserForm in Access 2000). Note that if you're using
Access 2000, you'll need to have a reference to the DAO
library to use this code (if you want, you can remove the
reference after you've set the property).

When you're making changes to the database as a developer,
you may want to re-enable the [Shift] key's bypass
functionality. You can do this by setting the
AllowBypassKey property to True, using a statement similar
to

CurrentDb.Properties("AllowBypassKey") = True

You can also remove the property completely from the
Properties collection to restore the [Shift] key's default
behavior. To do so, use the Delete method in a statement
such as

CurrentDb.Properties.Delete "AllowBypassKey"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top