Code:
Private Sub Login_Click()
Static count As Integer
'Verify if data is entered in the username box
If IsNull(Me.EmployeeID) Or Me.EmployeeID = "" Then
MsgBox "Please enter a username.", vbOKOnly, "Required Data"
Me.EmployeeID.SetFocus
Exit Sub
End If
'Verify if data is entered in the password box
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Please enter a Password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
If DCount("*", "tblEmployee", "strEmployeeId & strPassword = '" & Me.EmployeeID & Me.Password & "'") > 0 Then
MsgBox "Access Granted", vbInformation, "Logging in....."
DoCmd.Close
DoCmd.OpenForm "Menu"
Else
MsgBox "Access Denied"
count = count + 1
If count = 3 Then
MsgBox "You have failed to login on three tries", vbCritical, "Exiting...."
DoCmd.CloseDatabase
End If
End If
End Sub