Newbie, Prevent user from stoping Autoexec Macro

V

verci

Hi, sorry if this semms stupid

Is there any way to prevent that a user could stop the execution af the
Autoexec Macro by pressing the shift key, I'm using Access XP, I need to
stop this from ever happening.

Best regards
 
K

Klatuu

The AllowBypassKeys is the way to go. One thing you have to be aware of,
however, is that one it is set and you can't use the shift key, you still
need a way in. One way to do it is to create an invisible control somewhere
on one of your forms you can click to allow you in. Another is, if you are
using Access security is to allow a specific group to get into development
mode. Then check during startup to see whether to disable or enable the
bypass key. In the example below, we used our own security and only someone
with the password for the DEV user could get in.
The way it works here is that if DEV wants to get into development mode, he
has to first log on through security with the correct user name (DEV) and
password. Once the code below has executed, the shift key is enabled. He
then has to log out and open the database again using the shift key. When
any other user logs in, the shift key is disabled and all future logins will
have it disabled. The trick here is that if you go into dev mode to do
maintenance, before you distribute your changes, be sure to log in as any
other user so the shift key will be disabled for the next log in.

If Me.txtname = "DEV" Then
ChangeProperty "AllowBypassKey", 1, True
Else
ChangeProperty "AllowBypassKey", 1, False
End If

Here is a function that changes the property. If the property does not
exist, the error handler creates it.

Function ChangeProperty(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
 
K

Keith

Klatuu said:
The AllowBypassKeys is the way to go. One thing you have to be aware of,
however, is that one it is set and you can't use the shift key, you still
need a way in. One way to do it is to create an invisible control
somewhere
on one of your forms you can click to allow you in.

There is a utility freely available that will set the AllowBypassKey
property for any database, a quick Google should find it.

Keith.
www.keithwilby.com
 

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