Password Tries

G

Guest

I could like to add additional code to track number of invalid password
tries attempted by user. After 3 times log-out automatically.


Private Sub PassWordLookUp_LostFocus()

'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 Sub
 
J

John Spencer (MVP)

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
 
G

Guest

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




John Spencer (MVP) said:
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
I could like to add additional code to track number of invalid password
tries attempted by user. After 3 times log-out automatically.

Private Sub PassWordLookUp_LostFocus()

'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 Sub
 
J

John Spencer (MVP)

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

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

John Spencer (MVP) said:
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
I could like to add additional code to track number of invalid password
tries attempted by user. After 3 times log-out automatically.

Private Sub PassWordLookUp_LostFocus()

'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 Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SetFocus Problem 4
Password Protect form 1
Macro to VBA 20
SplitFormDatasheet property 6
Password programming 4
run-time error 3075 - help 3
Choose Form that Loads Based on Login 6
Password at Login Form 6

Top