I am new to Access and need some help with adding a search box onto a Sub form.
I added a search box on my Main form that has a combo box and a text box which is accessed with a command button, it works great.
Here is the code:
Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter Employers based on search criteria
Form_Employers.RecordSource = "select * from Employers where " & GCriteria
Form_Employers.Caption = "Employers (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close Search Form
DoCmd.Close acForm, "EmployersSearch"
MsgBox "Results have been filtered."
End If
End Sub
I would like to use the same thing on my 'Jobs' Sub form. How would I change to code have the correct reference? Any help would be greatly appreciated.
Thanks!