suppress the key SHIFT on open a access DB

  • Thread starter Thread starter TNL
  • Start date Start date
T

TNL

Hi,
I have access 2000.

when a user opens my DB, the macro autoexec will be
called, but the users can press the key SHIFT to suppress
this running.

I want, that the autoexec macro allways runs, when the DB
is opened.

How can I do?

TNL
 
You need to set the database property "AllowBypassKey" to False.

This property is user-defined, and therefore does not exist in a database by
default. The following procedure will set a property on any object,
creating it if it does not already exist:

Public Sub SetProperty(obj As Object, PropName As String, _
PropVal As Variant, Optional PropType As Integer = dbText)
On Error GoTo ProcErr
obj.Properties(PropName) = PropVal
Exit Sub
CreateProperty:
Dim prop As Property
Set prop = obj.CreateProperty(PropName, PropType, PropVal)
obj.Properties.Append prop
Exit Sub
ProcErr:
With Err
If .Number = 3270 Then Resume CreateProperty
.Raise .Number, .Source, _
"Error setting property " & PropName & vbCrLf & .Description
End With
End Sub

You could just enter the following in the debug window:
SetProperty CurrentDb, "AllowBypassKey", False, dbBoolean

However, you will have no way to turn the option back on again, because you
will have (presumably) also hidden the database window and turned off Access
special keys. You'd be better to write this code in *another* database:

Sub SetAllowBypassKey( sDbName as string, fOption as Boolean)
Dim db as DAO.Database
Set db = OpenDatabase( sDbName, false, false)
SetProperty db, "AllowBypassKey", fOption, dbBoolean
db.Close
End Sub

You can then use this procedure to turn the property on or off in any
database.
 
Thanks
-----Original Message-----
You need to set the database property "AllowBypassKey" to False.

This property is user-defined, and therefore does not exist in a database by
default. The following procedure will set a property on any object,
creating it if it does not already exist:

Public Sub SetProperty(obj As Object, PropName As String, _
PropVal As Variant, Optional PropType As Integer = dbText)
On Error GoTo ProcErr
obj.Properties(PropName) = PropVal
Exit Sub
CreateProperty:
Dim prop As Property
Set prop = obj.CreateProperty(PropName, PropType, PropVal)
obj.Properties.Append prop
Exit Sub
ProcErr:
With Err
If .Number = 3270 Then Resume CreateProperty
.Raise .Number, .Source, _
"Error setting property " & PropName & vbCrLf & .Description
End With
End Sub

You could just enter the following in the debug window:
SetProperty CurrentDb, "AllowBypassKey", False, dbBoolean

However, you will have no way to turn the option back on again, because you
will have (presumably) also hidden the database window and turned off Access
special keys. You'd be better to write this code in *another* database:

Sub SetAllowBypassKey( sDbName as string, fOption as Boolean)
Dim db as DAO.Database
Set db = OpenDatabase( sDbName, false, false)
SetProperty db, "AllowBypassKey", fOption, dbBoolean
db.Close
End Sub

You can then use this procedure to turn the property on or off in any
database.





.
 
Back
Top