3 strikes and you’re out

Renoir

Registered User.
Local time
Today, 13:14
Joined
May 31, 2007
Messages
42
Greetings wise ones
I have a small problem figuring out how to include the “3 strikes and you’re out” code within my login form. I did get a start by using some code that I found in this forum (I can’t recall the name of the author, thanks to him/her in any case). However, is doesn’t seem to work. Went the punter puts in the wrong password for the 4th time, the application is supposed to close – but is doesn’t. Any help will be greatly appreciated. The code is as follows:
Private Sub cmdLogin_Click()
Dim strUser As String
Dim strPWD As String
Dim intUSL As Integer

strUser = Me.txtUser
If DCount("[Password]", "Staff", "[UserID]='" & Me.txtUser & "'") > 0 Then
strPWD = DLookup("[Password]", "Staff", "[UserID]='" & Me.txtUser & "'")
If strPWD = Me.txtPwd Then
intUSL = DLookup("[AccessLevel]", "Staff", "[UserID]='" & Me.txtUser & "'")

Select Case intUSL
Case 1
DoCmd.OpenForm "Home", acNormal
Case 2
DoCmd.OpenForm "Home", acNormal, , , acFormReadOnly
Case 3
MsgBox "Not configured yet", vbExclamation, "Not configured"
Case 4
MsgBox "Not configured yet", vbExclamation, "Not configured"
End Select
DoCmd.Close acForm, "Login Dialog", acSaveNo
Else
If MsgBox("You entered an incorrect password" & vbCrLf & _
"Would you like to re-end your password?", vbQuestion + vbYesNo, "Restricted Access") = vbYes Then
Me.txtPwd.Value = ""
Counter = Counter + 1
If Counter = 3 Then
MsgBox "You have entered an incorrect password too many times. This database will now close!", vbCritical, "Wrong password!"
DoCmd.Quit
End If
Else
DoCmd.Quit
End If
End If
End If
End Sub
 
Do you have this anywhere (preferably at the top) in the same file where you have that sub?
Code:
Private Counter As Integer
If not, add it :)
 
Do you have this anywhere (preferably at the top) in the same file where you have that sub?
Code:
Private Counter As Integer
If not, add it :)

Actually, another way would be in the cmdLogin_Click() sub:

Static Counter As Integer
 
better still, 3 strikes, and then dont close, but carry on, and process anything as a failure

that way, they wont know they might be getting the password correct
 

Users who are viewing this thread

Back
Top Bottom