Use of Wildcard in String Expression

N

NEWER USER

I am trying to get the wildcard syntax "*" correct on the query grid in the
following and have struggled. Any help appreciated.

InStr([Enter Food Product(s)],[Food Group])

Criteria is >0

Instead of typing Milk,Butter,Bread,Lettuce when prompted in the Parameter
Value

I would like to be able to type Mi, Bu,Br,Le. Can this be accomplished?
 
J

Jerry Whittle

In the

In the criteria for the proper field:

Like "*" & [Enter Food Product] & "*"

The above will find BU anywhere in the string. If you want it to start with
BU:

Like [Enter Food Product] & "*"
 
J

John Spencer

Since INSTR does not use wildcards I don't see how your question applies.

You might be able to use something like the following if you wanted to match
on just two characters.

InStr([Enter Food Product(s)], Left([Food Group],2))



John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
N

NEWER USER

That works for well for searching one value. What if I want to return Milk
or Bread ? I get an empty string when doing so. This is why I was using
InStr and separating values with a comma (milk,bread). My users may not
spell correctly so I wanted a wildcard to minimize/avoid spelling errors.
Any other suggestions with wildcard and InStr function?

Jerry Whittle said:
In the

In the criteria for the proper field:

Like "*" & [Enter Food Product] & "*"

The above will find BU anywhere in the string. If you want it to start with
BU:

Like [Enter Food Product] & "*"
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


NEWER USER said:
I am trying to get the wildcard syntax "*" correct on the query grid in the
following and have struggled. Any help appreciated.

InStr([Enter Food Product(s)],[Food Group])

Criteria is >0

Instead of typing Milk,Butter,Bread,Lettuce when prompted in the Parameter
Value

I would like to be able to type Mi, Bu,Br,Le. Can this be accomplished?
 
N

NEWER USER

You answered my question. No wildcards allowed in INSTR

John Spencer said:
Since INSTR does not use wildcards I don't see how your question applies.

You might be able to use something like the following if you wanted to match
on just two characters.

InStr([Enter Food Product(s)], Left([Food Group],2))



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

NEWER said:
I am trying to get the wildcard syntax "*" correct on the query grid in the
following and have struggled. Any help appreciated.

InStr([Enter Food Product(s)],[Food Group])

Criteria is >0

Instead of typing Milk,Butter,Bread,Lettuce when prompted in the Parameter
Value

I would like to be able to type Mi, Bu,Br,Le. Can this be accomplished?
.
 

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