Here is my situation. I have a login form that inputs the user for ID and Name. I have 2 tables that has the user credentials. One table is coaches and one is for hourly. I want to autopopulate the Name text box in my form from the ID text box. User A is a coach and User B is an hourly. I want User A to input their ID in the ID text box and press a button to check the ID, then I want it to autopopulate the Name of User A from the CoachTable into the Name text box on my form. User B is an hourly, I want it to do the same thing as User A, but look into the HourlyTable. Here is my code and I know it doesn't work just my thoughts on how to do it.
Code:
Private Sub Command19_Click()
Dim rs As DAO.Recordset
Dim txtID As Variant
txtID = Forms![LoginForm2]![txtEmployeeID]
txtName = Forms![LoginForm2]![Text13]
Set rs = CurrentDb.OpenRecordset("SELECT * FROM HourlyTable WHERE EmployeeID = '" & txtID & "'", dbOpenDynaset)
Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM CoachTable WHERE EmployeeID = '" & txtID & "'", dbOpenDynaset)
Forms![LoginForm2]![Text13].SetFocus
txtName = DLookup("EmployeeID", "HourlyTable", "EmployeeID = '" & txtID & "' AND CoachName='" & txtName & "'")
txtName = DLookup("EmployeeID", "CoachTable", "EmployeeID = '" & txtID & "' AND CoachName='" & txtName & "'")
End Sub