Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AllowBypassKey

Status
Not open for further replies.

scoobey

Technical User
Sep 18, 2001
32
0
0
GB
Can any one helpme here? I'mquite new toVBA, but i'm trying to prevent users from bypassing the autoexec macro by pressing the shift key. I have looked at help files and read a few solutions on the threads, but I keep getting error messages. I'm not sure how to run the code either. When I do, I keep getting a 'user defined type not defined' error message, which highlights 'Dim dbs As Database' inmy code. I'm really pulling my hair out onthis one. Any help would be grately appreaciated, it's more than likely tobe something i'm doing/not doing?
 
This happens all the time .. in your VB window go to TOOLS REFERENCES and make sure MS DAO 3.6 Library is installed. Ashley L Rickards
SQL DBA
 
Public Function lockDB()

On Error GoTo HandleErr
vKey = InputBox("Enter value to set key", "Enter Code")
If Val(vKey) = 1234 Then
SetBypassKey True
Else
SetBypassKey False
End If
lockDB = True
ExitHere:
Exit Function
' Error handling block added by Error Handler Add-In. DO NOT EDIT this block of code.

' Automatic error handler last updated at 12-20-2000 14:53:36 'ErrorHandler:$$D=12-20-2000 'ErrorHandler:$$T=14:53:36

HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Utility.lockDB" 'ErrorHandler:$$N=Utility.lockDB

End Select

' End Error handling block.
End Function

Sub SetBypassKey(ByVal vKey As Boolean)
Dim cp As CurrentProject
On Error GoTo HandleErr
Set cp = CurrentProject

cp.Properties("AllowBypassKey") = vKey

ExitHere:
Exit Sub

' Error handling block added by Error Handler Add-In. DO NOT EDIT this block of code.

' Automatic error handler last updated at 12-20-2000 14:53:49 'ErrorHandler:$$D=12-20-2000 'ErrorHandler:$$T=14:53:49

HandleErr:

Debug.Print Err.Number

Select Case Err.Number

Case 2455

cp.Properties.Add "AllowBypassKey", vKey

Resume Next

Case Else

MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Utility.SetBypassKey" 'ErrorHandler:$$N=Utility.SetBypassKey

End Select

' End Error handling block.

End Sub


This is what I wrote for that...
hth
Alcar
 
Thanks for all the help guys - that works ASH001 - you are a star BUT I'm still having problems. When I run the code for the 'ByPassKey' that comes with the access help file, it comes up with 'Type Mismatch - Run Time error 13'. It then takes me to the code and highlights the following line 'Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)'. I called the function with an onLoad event timer in my startup form like this 'ChangeProperty "AllowBypassKey", dbBoolean, False'. Any other clues guys???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top