Using wild cards in a query.

N

Nick

In the criteria of a query field called Description. I am
using a control from a form but unless I type in the full
description I get no records returned.
I would like to use a keyword and wild cards, eg.
*Keyword*, to return all records containing the keyword in
the description field.

Is this possible?
All help would be appreciated.

Nick
 
J

John Vinson

In the criteria of a query field called Description. I am
using a control from a form but unless I type in the full
description I get no records returned.
I would like to use a keyword and wild cards, eg.
*Keyword*, to return all records containing the keyword in
the description field.

Is this possible?
All help would be appreciated.

Nick

Certainly (and Access wouldn't be much of a database if you couldn't
do this!)

The LIKE operator is used instead of the default = operator to use
criteria with wildcards. A crieterion of

LIKE "*xyz*"

on the Description field will find any record where xyz occurs
anywhere in Description.

More flexibly, you can prompt the user for a keyword:

LIKE "*" & [Enter keyword:] & "*"

will search for whatever keyword the user enters when prompted.
 
N

Nick

John,
Thank you for the assistance but I'm still having trouble.
I tried many combinations like this - Like "*[Forms]!
[Search Boxes]![Search]*" but no luck. Can you tell me
where I'm going wrong?

Nick

-----Original Message-----
In the criteria of a query field called Description. I am
using a control from a form but unless I type in the full
description I get no records returned.
I would like to use a keyword and wild cards, eg.
*Keyword*, to return all records containing the keyword in
the description field.

Is this possible?
All help would be appreciated.

Nick

Certainly (and Access wouldn't be much of a database if you couldn't
do this!)

The LIKE operator is used instead of the default = operator to use
criteria with wildcards. A crieterion of

LIKE "*xyz*"

on the Description field will find any record where xyz occurs
anywhere in Description.

More flexibly, you can prompt the user for a keyword:

LIKE "*" & [Enter keyword:] & "*"

will search for whatever keyword the user enters when prompted.


.
 
J

John Vinson

John,
Thank you for the assistance but I'm still having trouble.
I tried many combinations like this - Like "*[Forms]!
[Search Boxes]![Search]*" but no luck. Can you tell me
where I'm going wrong?

That syntax will return all records which contain the literal text
string [Forms]![Search Boxes]![Search] - and I rather doubt that any
of your table records do!

Concatenate the VALUE of the form control, not its name:

LIKE "*" & [Forms]![Search Boxes]![Search] & "*"
 

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