I am trying to compare data from a user input to a recordset. If the data is found in the recordset, open a form, if it isnt found, open a different form. If the user inputs no data and presses enter, display error saying invalid ID.
Code:Private Sub Command12_Click() Dim rs As DAO.Recordset Dim txtID As Variant txtID = Forms![LoginForm2]![txtEmployeeID] Set rs = CurrentProject.Connection.Execute("SELECT * FROM DataTable WHERE EmployeeID IS NULL") If Len(txtID) > 0 Then While Not rs.EOF If rs = txtID Then DoCmd.OpenForm "frmMain", acNormal Else DoCmd.OpenForm "HourlyForm", acNormal End If Else MsgBox "Please enter a valid Associate ID" rs.MoveNext Wend Set rs = Nothing End If Exit Sub End Sub