David627
05-15-2009, 09:34 AM
I have a search form that I obtained which allows the user to pick which criteria they wish to search in a combo box and then a text box where the string is entered.
Everything works fine excpet date. I get a Run time error 3075: "Syntax error (missing operator) in query expression 'Entry Date LIKE '*1/5/09*"
(1/5/09 is the date I choose)
Code follows:
Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter frmCHECKS based on search criteria
Form_CHECKS.RecordSource = "select * from CHECKS where " & GCriteria
Form_CHECKS.Caption = "CHECKS (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close frmSearch
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
End If
End Sub
------------------
Thoughts?
Thank you
David
Everything works fine excpet date. I get a Run time error 3075: "Syntax error (missing operator) in query expression 'Entry Date LIKE '*1/5/09*"
(1/5/09 is the date I choose)
Code follows:
Private Sub cmdSearch_Click()
If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
MsgBox "You must select a field to search."
ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
MsgBox "You must enter a search string."
Else
'Generate search criteria
GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"
'Filter frmCHECKS based on search criteria
Form_CHECKS.RecordSource = "select * from CHECKS where " & GCriteria
Form_CHECKS.Caption = "CHECKS (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"
'Close frmSearch
DoCmd.Close acForm, "frmSearch"
MsgBox "Results have been filtered."
End If
End Sub
------------------
Thoughts?
Thank you
David