Hi
I have a form with a command button which on the 'On Click' event has the following code:
PasswordCheck
DoCmd.OpenForm "frmStartFormCarSales"
Password Check is a Public Function which allows the user to have three attempts to enter the correct password, at which point the database closes. the code for Password Check is below
Dim Message, title, MyValue
Message = "Enter Password" ' Set prompt.
title = "Password Check" ' Set title.
' Display message, title.
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "tblPassword") Then
PasswordCheck = True
Else
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "TblPassword") Then
PasswordCheck = True
Else
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "TblPassword") Then
PasswordCheck = True
Else
retvalue = MsgBox("You have had three attempts, Database Will Now Close", vbOKOnly)
DoCmd.Quit
End If
End If
End If
However the input box has OK and Cancel, but if you click cancel the second and third chances come up and then the databse closes. What i want is if Cancel is clicked then the 'On Click' event is cancelled.
Can someone please help
thanks
Richard
I have a form with a command button which on the 'On Click' event has the following code:
PasswordCheck
DoCmd.OpenForm "frmStartFormCarSales"
Password Check is a Public Function which allows the user to have three attempts to enter the correct password, at which point the database closes. the code for Password Check is below
Dim Message, title, MyValue
Message = "Enter Password" ' Set prompt.
title = "Password Check" ' Set title.
' Display message, title.
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "tblPassword") Then
PasswordCheck = True
Else
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "TblPassword") Then
PasswordCheck = True
Else
MyValue = InputBox(Message, title)
If MyValue = DLookup("Password", "TblPassword") Then
PasswordCheck = True
Else
retvalue = MsgBox("You have had three attempts, Database Will Now Close", vbOKOnly)
DoCmd.Quit
End If
End If
End If
However the input box has OK and Cancel, but if you click cancel the second and third chances come up and then the databse closes. What i want is if Cancel is clicked then the 'On Click' event is cancelled.
Can someone please help
thanks
Richard