A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

wildcard searches



 
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2008, 10:21 PM posted to microsoft.public.access.queries
2Blessed4Stress
external usenet poster
 
Posts: 30
Default wildcard searches

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]& "?*"
  #2  
Old July 23rd, 2008, 10:56 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 2,364
Default wildcard searches

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
'================================================= ===


2Blessed4Stress wrote:
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]& "?*"

  #3  
Old July 24th, 2008, 07:24 PM posted to microsoft.public.access.queries
2Blessed4Stress
external usenet poster
 
Posts: 30
Default wildcard searches

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

"John Spencer" wrote:

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
'================================================= ===


2Blessed4Stress wrote:
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]& "?*"


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.