-----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.
.