Count of incorrect password ?? (1 Viewer)

Mish_h

Registered User.
Local time
Today, 01:13
Joined
Mar 30, 2006
Messages
18
I have three command buttons which when clicked on open different forms. These forms are first password protected with a custom password form
I would like to implement a function so that if the incorrect password is typed in 3 times then it does something like exits the program.

Can anyone help / point me to an example that i can apply to my code..
Thanks

Here is the code for my check password cmd button.

Dim strInput As String
Dim strMsg As String

strInput = txt_Password
strMsg = "This form Password Protected. Please Enter The Correct Password."

Select Case intFormOpen
Case 1
If strInput = "123profile" Then 'password is correct
DoCmd.Close acForm, "Frm_Password"
DoCmd.OpenForm "Frm_AddNew", acNormal, "", "", , acDialog
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Please Try agian"
Exit Sub
End If
Case 2
If strInput = "123profile" Then 'password is correct
DoCmd.Close acForm, "Frm_Password"
DoCmd.OpenForm "Frm_Edit", acNormal, "", "", , acDialog
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Please Try agian"
Exit Sub
End If
Case 3
If strInput = "123profile" Then 'password is correct
DoCmd.Close acForm, "Frm_Password"
DoCmd.OpenForm "Frm_Delete", acNormal, "", "", , acDialog
Else 'password is incorrect
MsgBox "Incorrect Password!" & vbCrLf & vbLf & "Please Try agian"
Exit Sub
End If
End Select
 

Bodisathva

Registered User.
Local time
Today, 04:13
Joined
Oct 4, 2005
Messages
1,274
Although declaring a global variable to store the number of incorrect attempts would be my first thought, Access has a tendency to reset globals when the form they are initialized in loses focus for a modal or pop-up...the msg box may or may not reset the count, I'd have to do some testing on that.

The easiest, most sure-fire method would be a hidden, unbound text box. Set the default value to 0 and increment the value with each successive, incorrect entry. You could even go so far as to place the value in a 'System Parameters' table so you could track incorrect entries but that is probably overkill unless you are worried about repeated security breaches.
 

norman

Registered User.
Local time
Today, 09:13
Joined
Apr 18, 2001
Messages
37
Hi

Some time ago I used a login system to check user passwords (or pin numbers) these were actually stored in a table but I am sure that the following could be adapted to suit your scenario.

This is used on the onclick event of your command buttons.
It needs an additional field [txtsecuritycounter] to be created on the form with its visible property set to no.

When the form is opened default value is set to 1

I had it set that if they didn't enter the correct pin after 3 attempts the database was closed completely. A bit drastic perhaps but it suited the requirements at that time.!

If Me! [txt_Password ]<> Me![Pinentered] Then

Me![Txtsecuritycounter] = [Txtsecuritycounter] + 1
If [Txtsecuritycounter] = 4 Then GoTo securitycount:
MsgBox "Invalid password, please try again"
Me![Pinentered] = ""
Me![Pinentered].SetFocus


GoTo finish:

End If

DoCmd.OpenForm "your form name" 'pin correct

securitycount:

MsgBox "SECURITY VIOLATION !" & Chr$(13) & Chr$(13) & "Please contact your Database Administrator", 48
DoCmd.Close
Quit



Dedicated programmers will throw their hands up in horror at the naming of the fields but my defence is that this was written some time ago before I new better (I hope!)


HTH

Norman
 

Users who are viewing this thread

Top Bottom