I have a form called "File Search" that contains an unbound textbox called "SrchMed_ID". I have added a button. I would like the button to take the number I enter into "SrchMed_ID" to see if it is present in my form called "File Tracking" (query for this form is "CheckOUT-IN_Input"); if the number I enter is present open to that record in the form other wise open the form on a new record.
Here is what I have so far it works, except for opening to the number I enter for my search. It opens the form to the first record.
Thank you for your help.
Private Sub srchfiles_Click()
Dim MedID As String
' Get Value from Medicaid_ID textbox on the Form:
Me.srchfiles.SetFocus
Me.SrchMed_ID.SetFocus
MedID = Me.SrchMed_ID.Text
If IsNull(DLookup("Last_Name", "CheckOUT-IN_Input", "Medicaid_ID = '" & SrchMed_ID & "'")) Then
' NAME is Null because the Medicaid_ID doesn't exist.
DoCmd.OpenForm "File Tracking", , , "Medicaid_ID = '" & SrchMed_ID & "'"
Else
' NAME is not Null because the Medicaid_ID does exist.
DoCmd.OpenForm "File Tracking"
End If
End Sub