Like operator in SQL

  • Thread starter Thread starter Crystal
  • Start date Start date
C

Crystal

I know this question has to have been asked one hundred
times, but I can't find an example that will help me in
this particular case. I need to set a recordset in DAO =
to this SQL string:

strSQL = "SELECT tblLabelFormats.Format," & _
" tblLabelFormats.Field," & _
" tblLabelFormats.Left," & _
" tblLabelFormats.Top," & _
" tblLabelFormats.Width," & _
" tblLabelFormats.Height" & _
" FROM tblLabelFormats" & _
" WHERE (((tblLabelFormats.Format)
Like '*Format*') AND" & _
" ((tblLabelFormats.Field)='imgBEL');"

Basically, I need all of the records whose "Format" field
has the word "Format" in it and whose "Field" field is =
to "imgBEL"

When I run this, I either get "Too few parameters,
Expected 1" or a syntax error. How do I use the Like
operator correctly in this scenario?

Any help would be greatly appreciated,
Crystal
 
For me it looks like you need an extra closing bracket
(")") at the end, before the semicolon:

" WHERE (((tblLabelFormats.Format) Like '*Format*') AND" &_
" ((tblLabelFormats.Field)='imgBEL'));"

See if that's it

Cheers

Chris
 
Hello Crystal,

The only thing I can see is that there are 5 "(" and 4 ")".

Maybe, stick the 5th ")" after: '*Format*'), for example"

Like '*Format*')) AND" & _

Also, and totally off-thread, nearly all of your field names are designated
as Reserved Words in Access. While I don't think this will cause problems
in your query, I'd be sure to use the ! instead of the . wherever possible,
especially in forms.
 

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

Similar Threads


Back
Top