Getting run-time error '3075': Syntax error (missing operator) in query expression 'Customer Number LIKE 'cv001"
My program allows an individual to choose a search category from a combobox: Customer Number (Text based NOT Number), Customer Name, Address, etc. and then search that category based on what they type. The database should then filter the list based on the results. For my test I chose customer number and then typed in cv001 when I received the error. When debugging the highlighted section is:
FORM_Payment.RecordSource = "SELECT * FROM Customers WHERE " & GCriteria
My code is below:
Private Sub Search_Click()
If Len(searchField) = 0 Or IsNull(searchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(searchString) = 0 Or IsNull(searchString) = True Then
MsgBox "You must enter a search criteria."
Else
'Generate search criteria
**GCriteria = searchField.Value & " LIKE '*" & searchString & "*'"**
'Filter Payment form based on search criteria
Form_Payment.RecordSource = "SELECT * FROM Citations WHERE " & GCriteria
Form_Payment.Caption = "Customers (" & searchField.Value & " contains '*" & searchString & "*')"
'Close Customer Search form
DoCmd.Close acForm, "Customer Search"
MsgBox "Results have been filtered."
End If
End Sub