Wild Card Searches (1 Viewer)

ddrew

seasoned user
Local time
Today, 03:35
Joined
Jan 26, 2003
Messages
911
Ive read loads of posts about Wildcard searches but am unable to find the answer to my problem. In one of my boxes on my search form the user places in the search criteria value, this can be from A1 - A16 all the way to G16. At the moment i'm using this as my seasrch query:

[Forms]![Search]![BoxNo]

So if I put in C1 then I get all the C1's, great. If I want to wildcard then I put in Like "*" & [Forms]![Search]![BoxNo] &"*", and again it works, this time it call enything with C1 in it i.e C13.

How can I adjust my query to do both, sometimes I only want the exact match othertimes I want to wildcard :confused:
 

Brianwarnock

Retired
Local time
Today, 03:35
Joined
Jun 2, 2003
Messages
12,701
Hi
This may seem strange but if you code
Like [Forms]![Search]![BoxNo] in the criteria then entering c1 on the form finds all c1 ; entering c1* finds all c1, c11 etc ; entering *c1* finds all containing c1 anywhere

Brian
 

ddrew

seasoned user
Local time
Today, 03:35
Joined
Jan 26, 2003
Messages
911
Sorry, not on my form it dosen't . If I write as you say Iget everything with C1 in it. :confused:
 

Brianwarnock

Retired
Local time
Today, 03:35
Joined
Jun 2, 2003
Messages
12,701
Not sure what you are saying
You have coded
Like [Forms]![Search]![BoxNo] in the criteria for the field

then if you enter c1 on the form you get all c1
if you enter c1* you get?? it should be all starting c1
if you enter *c1* it should be anything containg c1

Just tested it works for me

brian
 

godofhell

Database Guru
Local time
Yesterday, 19:35
Joined
May 20, 2005
Messages
180
Try simply putting Like [Forms]![Search]![BoxNo] & "*", this should return anything that starts with C1 but not things that do not start with C1 so MyC1 will not show, if you want the users to be able to build their own search then provide to text boxes, on 1 they select "Like", "=" and then on the 2nd they put their value, then you build your criteria accordingly. Doing it from 1 text box your defined criteria will always take over and it will not know if you meant C1 only or like C1 or myC1, etc. Your choices are Like "*" & [Forms]![Search]![BoxNo] for Values that start with anything and end with C1, Like "*" & [Forms]![Search]![BoxNo] & "*" for values that start, end, or include C1, Like [Forms]![Search]![BoxNo] & "*" for values that start with C1, and last but not least [Forms]![Search]![BoxNo] for values that are = to C1.
 

Users who are viewing this thread

Top Bottom