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.
 
Back
Top