Your code looks wonky (technical term
)
Here is a snippet of the code
Code:
If Not IsNull(Make) Then
strWhere = strWhere & "([Make] = """ & [Forms]![Search1]![Text114] & """) AND "
End If
This makes no sense. What is "[Forms]![Search1]![Text114]"????
Here is a snippet from Allen Browne's code
Code:
If Not IsNull(Me.txtFilterCity) Then
strWhere = strWhere & "([City] = """ & Me.txtFilterCity & """) AND "
End If
"Me.txtFilterCity" is the text box control on the form that is being checked to see if the control is null or not (or the length is zero).
"[City]" is the field in the recordsource
"([City] = """ & Me.txtFilterCity & """) is creating the comparison between the text box control and the field in the record source.
Your code is not the same (disregarding the difference in field/control names.
To have your code snippet match Allen's snippet (in structure), it should look like:
Code:
If Not IsNull([Forms]![Search1]![Text114]) Then
strWhere = strWhere & "([Make] = """ & [Forms]![Search1]![Text114] & """) AND "
End If
I always take the time to rename controls, so I would have renamed the text box control for the "Make" data you want to search for to "tbMake" (the prefix tb = text box).
Then the code snippet would be
Code:
If Not IsNull([Forms]![Search1]![tbMake]) Then
strWhere = strWhere & "([Make] = """ & [Forms]![Search1]![tbMake] & """) AND "
End If
This could be shortened to
Code:
If Not IsNull(Me.tbMake) Then
strWhere = strWhere & "([Make] = """ & Me.tbMake & """) AND "
End If
It also looks like the last "IF" statement is missing the " AND " text.
What is the complete routine for searching??