I have a client database that I would like to search. I am able to search the main form, however I am unable to search my subform and have the main form display the corresponding record.
The code I have used to search my main form is as follows:
Private Sub cmdSearch_Click()
If Len(cboSearchCriteria) = 0 Or IsNull(cboSearchCriteria) = True Then
MsgBox "Please select a Search Criteria."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "Please enter something to search for."
'Filter frmClients based on Search Criteria
Form_frmClients.RecordSource = "select * from tblClients where " & GCriteria
DoCmd.Close acForm, "frmSearch"
MsgBox "Database has been searched. Matching records are now displayed"
My users will select from a drop-down menu the type of information they are looking and then type into a text box the search string.
When I try to change this code to work with my subform, it will display the correct subform record, but not the corresponding main form record. Everything is connected with a primary code ClientID. The Client Table (main form) and facilty table (sub form) has a one to many relationship. There is a possibility that a client as more than one facility associated with it...is it possible for them all to show up and not just the one matching the search criteria?