Help with login attempts

jtm013

New member
Local time
Today, 07:13
Joined
Nov 17, 2014
Messages
6
Hello, I have a login form which is working well with the exception of login attempts. It should only allow a limited number, but currently this function is not working. I am new to vba and hoping I just missed something simple.

Thanks in advance.

Private Sub VerificationButton_Click()

'Check to see if data is entered into the UserName combo box

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

'Check to see if data is entered into the password box

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

'Check value of password in tblEmployees to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("Pwd", "Tbl_Log_In_Data", _
"[EmpNumber]=" & Me.cboEmployee.Value) Then


EmpNumber = Me.cboEmployee.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Suggestion Review Form"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 2 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 2 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit

End If

End Sub
 
Use the Debugger to single step through your code, you'll find the error.
 
You write problem is solved, but you didnt write how was it solved.

Where did you declared intLogonAttempts?

You can also use hidden text box on the form to count login attemts.
 
I also see where the user could reopen the database and try again. I'd put a yes/no field in the employee table to lock them out.
 

Users who are viewing this thread

Back
Top Bottom