V
VBDogg
Guest
ok... I am trying to make a filter through a forum in visual basics.
I first make a text box which i want to type information into.
I then make a label box which the information gets stored in.
Then the Filter button (commands are below) will take the information from the label box and place it in a filter.
It should bring up all the rows that have matching text (anywhere in the string) in a report which i compiled.
It works just fine until i begin to use wildcards so it searches the whole string for a match instead of getting an exact match.
Private Sub Command28_Click()
Dim FilterSTR As String
'Build SQL String
If Text37 <> "" Then
'copy text (eg. "WHATEVER") to the label
Label31.Caption = Text37
FilterSTR = "[" & "Category" & "]" & " = " & "Like " & Chr(34) & "*" & Label31.Caption & "*" & Chr(34)
'make filter look like [category] = Like "*WHATEVER*"
'[Category] is the column i want to search for a string with "WHATEVER" in it
End If
If FilterSTR <> "" Then
'Set the Filter property
Reports![RptReport].Filter = FilterSTR
'Turn filter on
Reports![RptReport].FilterOn = True
Else
Reports![RptReport].FilterOn = False
End If
End Sub
this is the error i recieve when i use wildcards...
"Syntax error (missing operator) in query expression '([Category] = Like "*WHATEVER*")'
I first make a text box which i want to type information into.
I then make a label box which the information gets stored in.
Then the Filter button (commands are below) will take the information from the label box and place it in a filter.
It should bring up all the rows that have matching text (anywhere in the string) in a report which i compiled.
It works just fine until i begin to use wildcards so it searches the whole string for a match instead of getting an exact match.
Private Sub Command28_Click()
Dim FilterSTR As String
'Build SQL String
If Text37 <> "" Then
'copy text (eg. "WHATEVER") to the label
Label31.Caption = Text37
FilterSTR = "[" & "Category" & "]" & " = " & "Like " & Chr(34) & "*" & Label31.Caption & "*" & Chr(34)
'make filter look like [category] = Like "*WHATEVER*"
'[Category] is the column i want to search for a string with "WHATEVER" in it
End If
If FilterSTR <> "" Then
'Set the Filter property
Reports![RptReport].Filter = FilterSTR
'Turn filter on
Reports![RptReport].FilterOn = True
Else
Reports![RptReport].FilterOn = False
End If
End Sub
this is the error i recieve when i use wildcards...
"Syntax error (missing operator) in query expression '([Category] = Like "*WHATEVER*")'
Last edited: