Hi,
I am trying to create a login id and password form in Access 2007. I got this code from a site, however when implemented, it is constantly showing an error "Invalid Password. Please try again" even when passwords are correct. I have tried almost every possible thing. Also the last part of three failed attempts is not working. Kindly check the code below and please help with the possible error. Any information would be of great help.
Private Sub Combo2_AfterUpdate()
Me.Text2.SetFocus
End Sub
Private Sub Command6_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.Combo2) Or Me.Combo2 = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Combo2.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.Text2) Or Me.Text2 = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.Text2.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this
'matches value chosen in combo box
If Me.Text2.Value = DLookup("strEmpPassword", "tblEmployees", _
"[lngEmpID]=" & Me.Combo2.Value) Then
DoCmd.Close acForm, [frmlogon], acSaveNo
DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Text2.SetFocus
End If
'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 admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Thanks in Advance
Aman
Bookmarks