Allow/Disallow Bypass Code

W

Wayne Aprato

I've used the following code many times in Access 97 to Allow or
Disallow the Bypass key to be used:

Sub SetBypassTrue()
SetBypass (False)
End Sub

Sub SetBypassFalse()
SetBypass (True)
End Sub

Function SetBypass(rbFlag As Boolean) As Integer
On Error GoTo SetBypass_Error
Dim db As Database
Set db = CurrentDb
db.Properties!AllowBypassKey = rbFlag
setByPass_Exit:
Exit Function

SetBypass_Error:
If Err = 3270 Then
' allowbypasskey property does not exist
db.Properties.Append db.CreateProperty("AllowBypassKey",
dbBoolean, rbFlag)
Resume Next
Else
' some other error message
MsgBox "Unexpected error: " & Error$ & " (" & Err & ")"
Resume setByPass_Exit
End If
End Function

When I try to use it in Access XP the code fails at the line:

Dim db As Database

The wierd part is if I insert the code into an Access 97 database and
then convert the database to Access XP (Access 2000 default save
version) the code works fine as it always has in Access 97.

Any help would be appreciated.

Regards.
 

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