Ok, after a lot more Googling, I found a site that told me I cannot use more than one table in a form without basing the form on a query.
Here's what I did:
I made a query called qrySites and it does this:
SELECT * FROM tblMainSites INNER JOIN tblMainCustomers ON tblMainSites.Customer = tblMainCustomers.CustomerID;
This gives me a recordset where the CustomerID
is associated with the Customer
name. I then changed the Record Source of the form frmSites
to this new query, and updated the appropriate Control sources.
Then, the Search function filters records like this:
Private Sub cmdSearch_Click()
Dim strFilter As String
strFilter = "tblMainCustomers.Customer LIKE ""*" & Me.txtSearch & "*"""
If IsNull(Me.txtSearch) Then
Me.Filter = "" 'Clears filter if text box is blank when searching
Me.FilterOn = False
Else
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
This gives the Me.Filter
method the proper input, which is just the Where
clause of the SQL query string.
I tested it, and the search works. The form also passes any changes through the query to the appropriate table, though I did have to check my control sources and some of the fields shared names in the tables.