Password Check and Cancel Event

rnutts

Registered User.
Local time
Today, 18:08
Joined
Jun 26, 2007
Messages
110
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
 
Hi,

you may need to re-analyse your problem:

1) Mask the password string. Use form's TextBox with passwod mask instead of InputBox.
2) Count the number of attempts.
3) Use DCount instead of DLookup. Use criterion in DCount (DLookup)!

See the attachment.
 

Attachments

Users who are viewing this thread

Back
Top Bottom