Add a static variable and increment it. When it reaches 3 failures, exit the database
Static intFailure as Integer
If intFailure = 3 then
DoCmd.Quit
Else
intFailure = intFailure + 1
'Your existing code here.
end if
Thank You, John
I am not sure of the placement of code.
Where is the variabel declaration placed. And what part of the code is tries
counter placed
> Add a static variable and increment it. When it reaches 3 failures, exit the database
>
[quoted text clipped - 36 lines]
> > End If
> > End Sub
John Spencer (MVP) - 05 Mar 2005 03:11 GMT
Probably something like the following.
Private Sub PassWordLookUp_LostFocus()
Static intFailure as Integer
If intFailure = 3 then
DoCmd.Quit
Else
intFailure = intFailure + 1
'test for blank password
If IsNull([PassWordLookUp]) Then
MsgBox ("Must Enter Valid Password")
LookupUserID.SetFocus
PassWordLookUp.SetFocus
PassWordLookUp = Null
Exit Sub
End If
'test for valid password
Dim strValidPassWord As Integer
strValidPassWord = DCount("*", "tblOperators", "[PassWord] ='" &
[PassWordLookUp] & "'")
If strValidPassWord = 0 Then
MsgBox "Invalid Password Entered"
LookupUserID.SetFocus
PassWordLookUp.SetFocus
PassWordLookUp = Null
Exit Sub
End If
End If
End Sub
> Thank You, John
>
[quoted text clipped - 42 lines]
> > > End If
> > > End Sub