Code to search 'any part of field'

  • Thread starter Thread starter AMH
  • Start date Start date
A

AMH

I use a form to search a text field in a query

The SQL view of the query looks like this

SELECT qryMainRefList.YR, qryMainRefList.TI, qryMainRefList.SO,
qryMainRefList.AU, qryMainRefList.[IN], qryMainRefList.AB
FROM qryMainRefList
WHERE (((qryMainRefList.AU)=[Forms]![frmSearch]![txtAU]))
ORDER BY qryMainRefList.YR DESC;

The problem is that when it searchs for the input from
[Forms]![frmSearch]![txtAU] it looks for a whole field value
I need to look for any part of the field and can not do it.
Thanks in advance

AMH
 
Look up the LIKE operator and Wildcard characters.

You probably need to end up with something like the following.

SELECT qryMainRefList.YR, qryMainRefList.TI, qryMainRefList.SO,
qryMainRefList.AU, qryMainRefList.[IN], qryMainRefList.AB
FROM qryMainRefList
WHERE (((qryMainRefList.AU) LIKE "*" & [Forms]![frmSearch]![txtAU] & "*"))
ORDER BY qryMainRefList.YR DESC;

By the way, thanks for posting your SQL string. It is much easier to understand
the problem and suggest solutions when this is done.
 
Thank you very much, it works.
Thanks again for the time you give for unexperienced users like me.
 
Back
Top