wildcard searches

2

2Blessed4Stress

I'm using a form for the user to input a part number exactly as it is. ex. #7-7
I then have a query that runs based on the value entered on the form.
It searches the Description field (text) to find the part anywhere within
the field. How do I structure my query to find the exact part number as
entered with characters? This is what I have in the criteria in my query....

like "*?" &[Forms]![frm_SrchDescForPart]![PartNumber]& "?*"
 
J

John Spencer

You have a small problem if your user enter
"#7-7"
The # sign will be seen as a wildcard character meaning any number. So
you will either need to train all the users to enter that # sign with
square brackets
"[#]7-7"
OR you can try a replace function to add the brackets
Replace([Forms]![frm_SrchDescForPart]![PartNumber],"#","[#]")
or you can try using ALIKE in place of the Like

ALIKE "%" & [Forms]![frm_SrchDescForPart]![PartNumber] & "%"

I don't know why you have the ? marks in your like since that says any
one character must exist before and after the user's input. So if the
part number was at the beginning or ending of the field, it would not be
found.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
2

2Blessed4Stress

Thank you. The ALIKE....works fine.

John Spencer said:
You have a small problem if your user enter
"#7-7"
The # sign will be seen as a wildcard character meaning any number. So
you will either need to train all the users to enter that # sign with
square brackets
"[#]7-7"
OR you can try a replace function to add the brackets
Replace([Forms]![frm_SrchDescForPart]![PartNumber],"#","[#]")
or you can try using ALIKE in place of the Like

ALIKE "%" & [Forms]![frm_SrchDescForPart]![PartNumber] & "%"

I don't know why you have the ? marks in your like since that says any
one character must exist before and after the user's input. So if the
part number was at the beginning or ending of the field, it would not be
found.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

I'm using a form for the user to input a part number exactly as it is. ex. #7-7
I then have a query that runs based on the value entered on the form.
It searches the Description field (text) to find the part anywhere within
the field. How do I structure my query to find the exact part number as
entered with characters? This is what I have in the criteria in my query....

like "*?" &[Forms]![frm_SrchDescForPart]![PartNumber]& "?*"
 

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