Wildcard form search

J

Johnny Bright

Hi there,

When I use the following code:
stLinkCriteria = "[strVendor]=" & "'" & Me![txtExpVend] & "'"
as part of my open form criteria obviously I get EXACTLY what is typed into
txtExpVend. I want to be able to find "Bay" for example, but if the data was
entered as "The Bay", this code won't find it. I've tried messing aboud with
the * sign but am not sure where to put it.

All help appreciated!

JR
 
K

Ken Snell \(MVP\)

Error in my just-sent post. This is the correct expression:

stLinkCriteria = "[strVendor] Like " & "'*" & Me![txtExpVend] & "*'"
 
B

Brendan Reynolds

stLinkCriteria = "[strVendor]=" & "'*" & Me![txtExpVend] & "*'"

The aim is that the result of the expression ends up looking like so ...

'*Bay*'
 
M

Marshall Barton

Johnny said:
When I use the following code:
stLinkCriteria = "[strVendor]=" & "'" & Me![txtExpVend] & "'"
as part of my open form criteria obviously I get EXACTLY what is typed into
txtExpVend. I want to be able to find "Bay" for example, but if the data was
entered as "The Bay", this code won't find it. I've tried messing aboud with
the * sign but am not sure where to put it.


stLinkCriteria = "strVendor='*" & Me![txtExpVend] & "*'"
 
B

Brendan Reynolds

Oops! Forgot to change the second "=" to "LIKE" ...

stLinkCriteria = "[strVendor] LIKE " & "'*" & Me![txtExpVend] & "*'"

--
Brendan Reynolds
Access MVP

Brendan Reynolds said:
stLinkCriteria = "[strVendor]=" & "'*" & Me![txtExpVend] & "*'"

The aim is that the result of the expression ends up looking like so ...

'*Bay*'

--
Brendan Reynolds
Access MVP

Johnny Bright said:
Hi there,

When I use the following code:
stLinkCriteria = "[strVendor]=" & "'" & Me![txtExpVend] & "'"
as part of my open form criteria obviously I get EXACTLY what is typed
into
txtExpVend. I want to be able to find "Bay" for example, but if the data
was
entered as "The Bay", this code won't find it. I've tried messing aboud
with
the * sign but am not sure where to put it.

All help appreciated!

JR
 
O

Ofer

Hi Marsh
Apperantly almost everybody forgot to change the = to Like

--
\\// Live Long and Prosper \\//


Marshall Barton said:
Johnny said:
When I use the following code:
stLinkCriteria = "[strVendor]=" & "'" & Me![txtExpVend] & "'"
as part of my open form criteria obviously I get EXACTLY what is typed into
txtExpVend. I want to be able to find "Bay" for example, but if the data was
entered as "The Bay", this code won't find it. I've tried messing aboud with
the * sign but am not sure where to put it.


stLinkCriteria = "strVendor='*" & Me![txtExpVend] & "*'"
 
J

Johnny Bright

Thanks all for that group effort! Works perfectly!

JR
--
www.brightfuture.ca/bright
My email address can be found on my site.


Ofer said:
Hi Marsh
Apperantly almost everybody forgot to change the = to Like

--
\\// Live Long and Prosper \\//


Marshall Barton said:
Johnny said:
When I use the following code:
stLinkCriteria = "[strVendor]=" & "'" & Me![txtExpVend] & "'"
as part of my open form criteria obviously I get EXACTLY what is typed into
txtExpVend. I want to be able to find "Bay" for example, but if the data was
entered as "The Bay", this code won't find it. I've tried messing aboud with
the * sign but am not sure where to put it.


stLinkCriteria = "strVendor='*" & Me![txtExpVend] & "*'"
 
Top