Hi! I am using the following code to search a form form a pop up form.
Private Sub cmdSearch_Click()
If Len(cboSearchField & vbNullString) > 0 Then
strCriteria = "[" & cboSearchField.Value & "] LIKE '*" & txtSearchString & "*' And "
End If
If Len(cboSearchField1 & vbNullString) > 0 Then
strCriteria = strCriteria & "[" & cboSearchField1.Value & "] LIKE '*" & txtSearchString1 & "*' And "
End If
If Len(strCriteria) > 0 Then
strCriteria = " Where " & Left$(strCriteria, Len(strCriteria) - 5)
End If
DoCmd.Close acForm, "frmSearch"
Form_frmServiceForm.RecordSource = "select * from [Service Table] " & strCriteria
MsgBox "Results have been filtered."
End Sub
Then using this code to open a report based off of the results.
DoCmd.OpenReport "Daily Service report", acViewPreview, , strCriteria
But I am getting an error that says "runtime error 3075
syntax error (missing operator) in query expression '(where [region] LIKE '*south*')." This is when I am searching the form for records containing the region as being south.
Any ideas on how to fix this??
Thanks!
Private Sub cmdSearch_Click()
If Len(cboSearchField & vbNullString) > 0 Then
strCriteria = "[" & cboSearchField.Value & "] LIKE '*" & txtSearchString & "*' And "
End If
If Len(cboSearchField1 & vbNullString) > 0 Then
strCriteria = strCriteria & "[" & cboSearchField1.Value & "] LIKE '*" & txtSearchString1 & "*' And "
End If
If Len(strCriteria) > 0 Then
strCriteria = " Where " & Left$(strCriteria, Len(strCriteria) - 5)
End If
DoCmd.Close acForm, "frmSearch"
Form_frmServiceForm.RecordSource = "select * from [Service Table] " & strCriteria
MsgBox "Results have been filtered."
End Sub
Then using this code to open a report based off of the results.
DoCmd.OpenReport "Daily Service report", acViewPreview, , strCriteria
But I am getting an error that says "runtime error 3075
syntax error (missing operator) in query expression '(where [region] LIKE '*south*')." This is when I am searching the form for records containing the region as being south.
Any ideas on how to fix this??
Thanks!