Login form trouble

binksmatthew

Registered User.
Local time
Today, 09:34
Joined
Mar 3, 2007
Messages
21
i have designed a form that allows users to log in. the username and password section works well. however, i also added a code that should make the application shut down after a user gets their password wrong three times but it is not working at all.
below is my coding:

If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
 
Where do you have this code in relation to your login code?
 
i have it at the end of my coding
 
Do you have intLoginAttempts declared in your command button on the login page as

Dim intLoginAttempts As Integer

If so, then each time you press the command button it will reset the variable back to zero and you will never get to 3. You will need to either declare it as static or put it in a standard module using a PUBLIC declaration.
 
no i dont have intLogonAttempts anywhere else in the coding. could this be the problem.
 
You need to declare it somewhere and if you don't and don't have OPTION EXPLICIT as one of your database options then it will basically create the variable for you each time; same result as putting Dim inLoginAttempts in the click event of the button-won't work. So, try adding
Code:
Static intLoginAttempts As Integer
in your click event of the form then it will hold the values until the form is closed.
 
i tried added the code to my form's On click settings but it still doesnt work. could you tell me how would i put OPTION EXPLICT as one of my database options please
 
sm04.png



sm05.png




sm06.png




sm07.png
 
cheers for the help bob but i decided to begin the form again and it works fine now.
 
Bob,
What tools are you using to make your excellent teaching pictures?
 
RG - Just using SnagIt. I went for years hearing about it but never trying it. Finally they had it on a computer at work and so I tried it out and I'm hooked. I paid for my own copy for home and it just blows me away with how quick and easy it is to use and how much you can actually do with it.

And, it's only $39.95 at http://www.snagit.com
 
I've really been impressed with many your posts when you drag out the pictures. Thanks for responding. I may have to delve into that myself. You've bailed me out with those pictures when I was not making any headway with words and I've been wanting to ask for a while now. The captions make it! Have a good one Bob.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom