By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

Count Bad Passwords

P: n/a
Hi group.

I can't get a part of coding to work. It's for a Log in part of a
system. So far it all work, apart from the last part. Where the
number of bad passwords are counted, and when there's 3 bad passwords
.....then the database should shut down.

This is the coding.

++++++++++++++++++++++++++++++++++++++++++++

Private Sub cmdLogin_Click()

'This checks that a User Name has been selected in the combobox

If IsNull(Me.Employee) Or Me.Employee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Employee.SetFocus
Exit Sub
End If

'Check to see that data has been entered in the password box

If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If

'Compares the typed password to the one in the table

If Me.Password.Value = DLookup("[Log Pwd]", "Log In TBL", "[Log ID]="
& Me.Employee.Value) Then
'Close logon form and open Welcome form

DoCmd.Close acForm, "LogIn", acSaveNo
DoCmd.OpenForm "Welcome Frm"

'Otherwise if password is wrong
'then say, Password Invalid
'And set focus to password field

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid
Entry!"
Me.Password.SetFocus
intLogInAttempts = intLogInAttempts + 1
End If

'If User Enters incorrect password 3 times
'Database will quit
If intLogInAttempts > 3 Then
MsgBox "You have entered the wrong password 3 times. Database will
now shut down. Please contact admin", vbCritical, "Restricted
Access!"
Application.Quit
End If

End Sub

++++++++++++++++++++++++++++++++++++++++++++
The "intLogInAttempts = intLogInAttempts + 1" line, and everything
after doesn't seem to work.

Would be grateful for any help.

Pretty Please!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Where and how is the variable 'intLogInAttempts' declared? I don't see the
declaration anywhere in the code you posted.

If you declare it within the procedure using the Static keyword, it should
work ...

Private Sub cmdLogin_Click()

Static intLogInAttempts As Integer
'etc.

See the help topic on the 'Static' keyword for more information.

--
Brendan Reynolds
"IronMan" <Th********@yahoo.com> wrote in message
news:ce**************************@posting.google.c om...
Hi group.

I can't get a part of coding to work. It's for a Log in part of a
system. So far it all work, apart from the last part. Where the
number of bad passwords are counted, and when there's 3 bad passwords
....then the database should shut down.

This is the coding.

++++++++++++++++++++++++++++++++++++++++++++

Private Sub cmdLogin_Click()

'This checks that a User Name has been selected in the combobox

If IsNull(Me.Employee) Or Me.Employee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Employee.SetFocus
Exit Sub
End If

'Check to see that data has been entered in the password box

If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If

'Compares the typed password to the one in the table

If Me.Password.Value = DLookup("[Log Pwd]", "Log In TBL", "[Log ID]="
& Me.Employee.Value) Then
'Close logon form and open Welcome form

DoCmd.Close acForm, "LogIn", acSaveNo
DoCmd.OpenForm "Welcome Frm"

'Otherwise if password is wrong
'then say, Password Invalid
'And set focus to password field

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid
Entry!"
Me.Password.SetFocus
intLogInAttempts = intLogInAttempts + 1
End If

'If User Enters incorrect password 3 times
'Database will quit
If intLogInAttempts > 3 Then
MsgBox "You have entered the wrong password 3 times. Database will
now shut down. Please contact admin", vbCritical, "Restricted
Access!"
Application.Quit
End If

End Sub

++++++++++++++++++++++++++++++++++++++++++++
The "intLogInAttempts = intLogInAttempts + 1" line, and everything
after doesn't seem to work.

Would be grateful for any help.

Pretty Please!

Nov 12 '05 #2

P: n/a
What do you mean by "dosen't work"? Do you get an error message? I don't see
a variable declaration for intLogInAttempts, so I'm not sure how it's
datatype is being handled.

Mike Storr
www.veraccess.com
"IronMan" <Th********@yahoo.com> wrote in message
news:ce**************************@posting.google.c om...
Hi group.


The "intLogInAttempts = intLogInAttempts + 1" line, and everything
after doesn't seem to work.

Would be grateful for any help.

Pretty Please!

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.