Wildcard in query

B

blake7

Hi All, I would like to kow how to use the "Like" and wildcard in a query, I
have a combo box which the user selects from this can contain words like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards
 
W

Wayne-I-M

It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar]," ")-1)
 
B

blake7

Hi Wayne, thanks for your reply, I have placed the code below in criteria and
then ran the query, it is now returning the word HONDA but nothing afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49]," ")-1)

Wayne-I-M said:
It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar]," ")-1)



--
Wayne
Manchester, England.



blake7 said:
Hi All, I would like to kow how to use the "Like" and wildcard in a query, I
have a combo box which the user selects from this can contain words like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards
 
D

Douglas J. Steele

Are you still appending the wildcard character at the end?

Originally, you had

Like [Forms]![ModelSelect]![Combo59] & "*"

Using Wayne's suggestion, you want

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1) & "*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in criteria
and
then ran the query, it is now returning the word HONDA but nothing
afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49],"
")-1)

Wayne-I-M said:
It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the
name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1)



--
Wayne
Manchester, England.



blake7 said:
Hi All, I would like to kow how to use the "Like" and wildcard in a
query, I
have a combo box which the user selects from this can contain words
like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE
statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards
 
W

Wayne-I-M

Hi

The criteria I gave will give you the 1st setion of the name as the
criteria, assuming that it is the 1st work before the space
eg
Ford Car1
Ford Car2
You will get all fords if you add the wildcard at the end "*"

Honda CarABC
Honda VAR XYZ
You will get all Hondas if you add the wildcard at the end "*"

If you don't add the wildcard "*" you will just get all the cars (of the
same type as the 1st word in your combo but not the 2nd part of the name -
which is what the wildcard does.

So, add this to the end "*"

Sorry I though from your orginal post you understood. Sorry for not being
specific.

Hope this helps




--
Wayne
Manchester, England.



blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in criteria and
then ran the query, it is now returning the word HONDA but nothing afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49]," ")-1)

Wayne-I-M said:
It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar]," ")-1)



--
Wayne
Manchester, England.



blake7 said:
Hi All, I would like to kow how to use the "Like" and wildcard in a query, I
have a combo box which the user selects from this can contain words like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards
 
W

Wayne-I-M

and don't forget the "&" sign (without the ")
sorry don't know the ral english word for this sign

--
Wayne
Manchester, England.



Wayne-I-M said:
Hi

The criteria I gave will give you the 1st setion of the name as the
criteria, assuming that it is the 1st work before the space
eg
Ford Car1
Ford Car2
You will get all fords if you add the wildcard at the end "*"

Honda CarABC
Honda VAR XYZ
You will get all Hondas if you add the wildcard at the end "*"

If you don't add the wildcard "*" you will just get all the cars (of the
same type as the 1st word in your combo but not the 2nd part of the name -
which is what the wildcard does.

So, add this to the end "*"

Sorry I though from your orginal post you understood. Sorry for not being
specific.

Hope this helps




--
Wayne
Manchester, England.



blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in criteria and
then ran the query, it is now returning the word HONDA but nothing afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49]," ")-1)

Wayne-I-M said:
It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar]," ")-1)



--
Wayne
Manchester, England.



:

Hi All, I would like to kow how to use the "Like" and wildcard in a query, I
have a combo box which the user selects from this can contain words like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards
 
B

blake7

Hi Guys, that works great although can the code also incorporate a single
word, I have just single words in the combo box and when selected it displays
the message "this expression is too complex to be evaluated etc etc"
Thanks both again for your help
Regards
Tony

Douglas J. Steele said:
Are you still appending the wildcard character at the end?

Originally, you had

Like [Forms]![ModelSelect]![Combo59] & "*"

Using Wayne's suggestion, you want

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1) & "*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in criteria
and
then ran the query, it is now returning the word HONDA but nothing
afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49],"
")-1)

Wayne-I-M said:
It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the
name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1)



--
Wayne
Manchester, England.



:

Hi All, I would like to kow how to use the "Like" and wildcard in a
query, I
have a combo box which the user selects from this can contain words
like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE
statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards


.
 
D

Douglas J. Steele

Slightly more complicated statement is all:

Like IIf(InStr([Forms]![FormName]![cboSelectCar]," ") > 1,
Left[Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1, [Forms]![FormName]![cboSelectCar]) & "*"


--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi Guys, that works great although can the code also incorporate a single
word, I have just single words in the combo box and when selected it
displays
the message "this expression is too complex to be evaluated etc etc"
Thanks both again for your help
Regards
Tony

Douglas J. Steele said:
Are you still appending the wildcard character at the end?

Originally, you had

Like [Forms]![ModelSelect]![Combo59] & "*"

Using Wayne's suggestion, you want

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1) & "*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in
criteria
and
then ran the query, it is now returning the word HONDA but nothing
afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49],"
")-1)

:


It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to
the
name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1)



--
Wayne
Manchester, England.



:

Hi All, I would like to kow how to use the "Like" and wildcard in a
query, I
have a combo box which the user selects from this can contain words
like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE
statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards


.
 
R

RonaldoOneNil

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar] & " "," ")-1) & "*"

blake7 said:
Hi Guys, that works great although can the code also incorporate a single
word, I have just single words in the combo box and when selected it displays
the message "this expression is too complex to be evaluated etc etc"
Thanks both again for your help
Regards
Tony

Douglas J. Steele said:
Are you still appending the wildcard character at the end?

Originally, you had

Like [Forms]![ModelSelect]![Combo59] & "*"

Using Wayne's suggestion, you want

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1) & "*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

blake7 said:
Hi Wayne, thanks for your reply, I have placed the code below in criteria
and
then ran the query, it is now returning the word HONDA but nothing
afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49],"
")-1)

:


It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the
name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1)



--
Wayne
Manchester, England.



:

Hi All, I would like to kow how to use the "Like" and wildcard in a
query, I
have a combo box which the user selects from this can contain words
like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE
statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards


.
 
B

blake7

Guys, Thanks to you both for all your help, it work perfectly now
Regards
Tony

RonaldoOneNil said:
Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar] & " "," ")-1) & "*"

blake7 said:
Hi Guys, that works great although can the code also incorporate a single
word, I have just single words in the combo box and when selected it displays
the message "this expression is too complex to be evaluated etc etc"
Thanks both again for your help
Regards
Tony

Douglas J. Steele said:
Are you still appending the wildcard character at the end?

Originally, you had

Like [Forms]![ModelSelect]![Combo59] & "*"

Using Wayne's suggestion, you want

Like
Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1) & "*"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

Hi Wayne, thanks for your reply, I have placed the code below in criteria
and
then ran the query, it is now returning the word HONDA but nothing
afterwards
? ie Honda Prelude or Honda Civic. Any further suggestions
Thanks Again

Left([Forms]![notprocessed]![combo49],InStr([Forms]![notprocessed]![combo49],"
")-1)

:


It will not work like you have it as you are saying
Like "Honda Prelude"&"somethingelse"
Like "Honda OtherName"&"somethingelse"

Use something like this in the criteria row (change cboSelectCar to the
name
of the combo box on your form)

Left([Forms]![FormName]![cboSelectCar],InStr([Forms]![FormName]![cboSelectCar],"
")-1)



--
Wayne
Manchester, England.



:

Hi All, I would like to kow how to use the "Like" and wildcard in a
query, I
have a combo box which the user selects from this can contain words
like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE
statement
to make the query return all the results that start with Honda.
I have tried code below but it returns only the specific model thats
selected in the Combo box and not all the range

Like [Forms]![ModelSelect]![Combo59] & "*"

can you help
Regards





.
 
J

John W. Vinson

Hi All, I would like to kow how to use the "Like" and wildcard in a query, I
have a combo box which the user selects from this can contain words like
Honda Civic, or Honda Prelude etc etc, I would like to use the LIKE statement
to make the query return all the results that start with Honda.

The reason you're having trouble is that your field is storing two distinct
pieces of information - a make (Honda) and a model (Prelude). These are two
interacting but DIFFERENT pieces of information. this process would be a lot
easier if you had the make in one field for the make, and a different field
for the model. It's always easier to splice together two distinct chunks than
to parse one thing into two.
 

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