Using 'like' in a form query

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 & "'"
 
D

Douglas J. Steele

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 & " ' "
 
C

Carl Rapson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top