These lines
Code:
EmployeeId = Nz(DLookup("strEmployeeid", "tblEmployee", "StrEmployeeId='" & Me.EmployeeId & "'"), "")
Password = Nz(DLookup("strPassword", "tblEmployee", "StrPassword='" & Me.Password & "'"), "")
really make no sense to me! It appears that you're using Variables (EmployeeID and Password) that have the same names as Controls on your Form, and after that I simply have no idea!
At any rate, I ran up a db with your Field and Control names, and the following accomplishes all of your stated goals:
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
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007