Cotswold
Active member
- Local time
- Today, 00:12
- Joined
- Dec 31, 2020
- Messages
- 703
Whilst I can specify a specific pattern for a Wildcard search using LIKE, I need to allow the user to use a Wildcard entry of WORD*WORD or *WORD*WORD* in a Query.
As a For-Instance; in bank imports NS&I can be referred to as NS&I, NS+I, or NS +I and from the imports what I want is to use are NS?I or NS*I in a LIKE statement. (NS&I is a British government quango. So the use of standardisation, consistency or logic are all of no moment to them)
In the CRITERIA of a Query I can use LIKE "*" & [FilterWord] & "*" or LIKE [FilterWord] & "*" which both work as expected.
If the user then enters :
*NS* or NS* then I can sort the Query to do the filters correctly. However, the first will include a pile of stuff like TRANSAC2ABC and Morrisons as well. The second will include everything starting with NS and followed by anything. Whilst the 2nd will (in this example) filter out just NS&I, NS+I, and NS +I. It will not be a universal solution for other searches as it could draw a huge amount of unwanted data into the filter. rendering it useless. Mainly because it doesn't give me the option to restrict the search after the last wildcard, by allowing the user to specify a word or character after the 2nd wildcard *. The theory being that a user will know a first section, the middle may change, or is something they are unsure of, but they know one or two characters at the end of the word to filter.
What I would like to do is allow the user to enter text as *ABC*XYZ or ABC*XYZ and then I thought I would be able to execute the query as follows:
LIKE "*" & [1stPartFilterWord] & "*" & [2ndPartFilterWord] or LIKE [1stPartFilterWord] & "*" & [2ndPartFilterWord] but neither syntax works at all.
I cannot find anything on the internet on User Entered Wildcards for Queries in MS Access. My question is does anyone know the correct syntax?
As a For-Instance; in bank imports NS&I can be referred to as NS&I, NS+I, or NS +I and from the imports what I want is to use are NS?I or NS*I in a LIKE statement. (NS&I is a British government quango. So the use of standardisation, consistency or logic are all of no moment to them)
In the CRITERIA of a Query I can use LIKE "*" & [FilterWord] & "*" or LIKE [FilterWord] & "*" which both work as expected.
If the user then enters :
*NS* or NS* then I can sort the Query to do the filters correctly. However, the first will include a pile of stuff like TRANSAC2ABC and Morrisons as well. The second will include everything starting with NS and followed by anything. Whilst the 2nd will (in this example) filter out just NS&I, NS+I, and NS +I. It will not be a universal solution for other searches as it could draw a huge amount of unwanted data into the filter. rendering it useless. Mainly because it doesn't give me the option to restrict the search after the last wildcard, by allowing the user to specify a word or character after the 2nd wildcard *. The theory being that a user will know a first section, the middle may change, or is something they are unsure of, but they know one or two characters at the end of the word to filter.
What I would like to do is allow the user to enter text as *ABC*XYZ or ABC*XYZ and then I thought I would be able to execute the query as follows:
LIKE "*" & [1stPartFilterWord] & "*" & [2ndPartFilterWord] or LIKE [1stPartFilterWord] & "*" & [2ndPartFilterWord] but neither syntax works at all.
I cannot find anything on the internet on User Entered Wildcards for Queries in MS Access. My question is does anyone know the correct syntax?