Private Sub cmdLogin_Click()
If IsNull(Me.cboUsers) Or Me.cboUsers = "" Then
MsgBox "You must select a User Name.", vbOKOnly, "Required Data"
Me.cboUsers.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter your Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
If Me.txtPassword.Value = DLookup("UserPassword", "tblUsers", _
"[UserID]=" & Me.cboUsers.Value) Then
MyUserID = Me.cboUsers.Value
DoCmd.Close acForm, "frmUserLogin", acSaveNo
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If
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