Option Compare DatabasePrivate intLogonAttempts As Integer
Private Sub cmdExit_Click()
DoCmd.Quit acQuitSaveAll
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.Users) Or Me.Users = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Users.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.Passtxt) Or Me.Passtxt = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.Passtxt.SetFocus
Exit Sub
End If
'Check value of password in Usernames to see if this matches value chosen in combo box
If Me.Passtxt.Value = DLookup("EmpPassword", "Usernames", "[EmpID]=" & Me.Users.Value) Then
MyEmpID = Me.Users.Value
'Enable ribbon and menu when log as Admin Account
'Close logon form and open splash screen
DoCmd.Close acForm, "LoginPOPUP", acSaveNo
DoCmd.OpenForm "MainFrm"
Else
MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
Me.Passtxt.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 your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub Users_AfterUpdate()
Me.Filter = "[EmpID]=" & Me.Users
Me.FilterOn = True
End Sub