Private Sub Command1_Click()
Dim intLogonAttempts As Long
'Verify Username
'Check to see if data is entered into the UserName combo box
If IsNull(Me.txtLoginID) Or Me.txtLoginID = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.txtLoginID.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 tblAssociateProfile to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[Surname]=" & Me.txtLoginID.Value) Then
DoCmd.Close acForm, "frmSplashScreen"
DoCmd.OpenForm "frmMenu"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword = ""
Me.txtLoginID.SetFocus
Me.txtPassword.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