Ok, the title doesn't really explain much. Here is my situation. I have a login form. 2 spots for users to input and ID and their name. I want to do error checking to see the user inputs a wrong name or wrong id with their corresponding name or ID. For example, I don't want User A to be able to login with User B's name. If User A inputs their ID and inputs User B's name, I want to show an error message stating the their is a mismatch of credentials. Here is my code
Code:
Private Sub Command12_Click()
Dim rs As DAO.Recordset
Dim txtID As Variant
txtID = Forms![LoginForm2]![txtEmployeeID]
txtName = Forms![LoginForm2]![Text13]
Set rs = CurrentDb.OpenRecordset("SELECT * FROM CoachTable WHERE EmployeeID = '" & txtID & "'", dbOpenDynaset)
If Len(txtID) > 11 And Len(txtName) > 5 Then
If rs.EOF Then 'no such person
DoCmd.OpenForm "HourlyForm", acNormal
Else
DoCmd.OpenForm "frmMain", acNormal
End If
Else
MsgBox "Please enter a valid Associate ID and/or Name"
End If
Exit Sub
End Sub