Using 'like' in a form query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to have my Office symbol query using 'like c* or c%' , using wildcards
like you can do in a query... this works but I can't use wildcards with it...
help?

DoCmd.OpenForm stDocName, acFormDS, , "[group]= '" & strGroup & "'" & "AND"
& "[office_symbol]= '" & "like" & strOffc & "'"
 
Your opening single quote is in the wrong place.

Rather than

& " [office_symbol]= ' " & "like" & strOffc & " ' "

it should be

& " [office_symbol]= " & "like ' " & strOffc & " ' "

Actually, you can simplify what you've got to

DoCmd.OpenForm stDocName, acFormDS, , "[group]= '" & strGroup & _
"' AND [office_symbol]= like '" & strOffc & "'"

Exagerated for clarity, that's

DoCmd.OpenForm stDocName, acFormDS, , "[group]= ' " & strGroup & _
" ' AND [office_symbol]= like ' " & strOffc & " ' "
 
Maarkr said:
I want to have my Office symbol query using 'like c* or c%' , using
wildcards
like you can do in a query... this works but I can't use wildcards with
it...
help?

DoCmd.OpenForm stDocName, acFormDS, , "[group]= '" & strGroup & "'" &
"AND"
& "[office_symbol]= '" & "like" & strOffc & "'"

The syntax should be:

"[office_symbol] LIKE '" & strOffc & "'"


Carl Rapson
 
Back
Top