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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|