Private Sub Password_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo ErrorRPT
Static LogonAttempts As Integer
Dim SaiCurrentUser As String
SaiCurrentUser = ""
If KeyCode = 13 Then
If Me.Password.Value = DLookup("[Password]", "[User Name]", "[User Name] = '" & Me.User_name & "'") Then
SaiCurrentUser = [User Name]
Forms![infokeeper]![Loginname] = SaiCurrentUser
DoCmd.Close acForm, "Login Screen", acSaveNo
DoCmd.OpenForm "Switchboard"
Else
LogonAttempts = LogonAttempts + 1
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.Password.SetFocus
Me.Password.Value = ""
End If
If LogonAttempts > 3 Then
MsgBox "You do not have permission to access this database.Please contact your database administrator."
Application.Quit
End If
End If
GoTo Endsubtxt
ErrorRPT:
Call ErrorRPT1
Endsubtxt:
End Sub