How can I combine these 2 buttons into 1 button?
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 IsNull(DLookup("EmployeeID", "CoachTable", "EmployeeID = '" & txtId & "' AND CoachName='" & txtName & "'")) Then
MsgBox "This is not a valid login"
Else
DoCmd.OpenForm "frmMain", acNormal
End If
Exit Sub
End Sub
Code:
Private Sub Command16_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)
If IsNull(DLookup("EmployeeID", "HourlyTable", "EmployeeID = '" & txtId & "' AND CoachName='" & txtName & "'")) Then
MsgBox "This is not a valid login"
Else
DoCmd.OpenForm "HourlyForm", acNormal
End If
End Sub