I used a different approach. I picked it up from here (sorry, I don't remember who posted it) and added a few modifications of my own.
I have a single record/single field table called tblByPass; the field is called ByPass and is a Yes/No type.
I put a command button (cmdSet) on one of the menu forms and set it's visible property to No. When I click this it toggles the Yes/No state of the field ByPass and depending on the state of ByPass calls either the EnableKey or DisableKey procedure.
This is the code for cmdSet:
Private Sub cmdSet_Click()
Dim dbTemp As Database
Dim rsTemp As Recordset
Set dbTemp = CurrentDb
Set rsTemp = dbTemp.OpenRecordset("tblByPass"
If rsTemp.Fields(0) = True Then
rsTemp.Edit
rsTemp.Fields(0) = False
EnableKey
Else
rsTemp.Edit
rsTemp.Fields(0) = True
DisableKey
End If
rsTemp.Update
rsTemp.Close
End Sub
And this is the code for the two subs:
Public Sub EnableKey()
Dim db As Database
Dim prp As Property
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, True)
db.Properties.Append prp
End Sub
Public Sub DisableKey()
Dim db As Database
Dim prp As Property
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prp
End Sub
It is a tad bit clunky but it does the trick. If the bypass key has been disabled, all you need to do is click on the "hidden" button to re-enable it, exit the database and then open it again using the shift key. When you are done making changes, simply click on the button again to disable. If you don't let your users in on the secret it's almost fool proof.
Larry De Laruelle
larry1de@yahoo.com