parameter query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm an Access novice and need help in setting up a parameter query. I want to
search across a table so that I can recover all records that have instances
of a word in either of two fields but I don't want it to be a fixed enquiry
e.g. I may want to search for "Scottish" and some time later search for
"cheese" but I don't want to set up a new query each time. The only wildcards
I can find are for single characters within a word e.g cheese*.
 
* isn't for a single character: it's for any number of characters. ? is the
wildcard for a single character.

If there are two fields you need to search, and you want to search for
whatever you input anywhere in the text, put

Like "*" & [Input Phrase] & "*"

as the criteria under both fields. Make sure you put them on separate lines
in the grid: if you put them on the same line, the phrase will have to be
present in both fields. Whatever you type between the square brackets (Input
Phrase in my example above) will appear in the prompt that the user gets.
You can put whatever you want there.

It's critical that you type it exactly the same in both places you use it.
If you don't, the user will be prompted twice.
 
Actually, the "*" wildcard is for any number of characters, including zero.

If you want to search within a field for an occurrence of the characters
"cheese", you'd hard-code the following into the search criterion:

Like * & cheese & *

To make it a parameter query, use something like:

Like * & [enter your search term] & *

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Set the criteria to for the first field to:
LIKE "*" & [Find What?] & "*"

Copy and paste that under the second field, but on a separate criteria line
(so it will do an or search).

As long as the prompt is identical, you will be asked one time for its
value.
 
Thanks everyone! That works! I had the syntax right but hadn't realised that
I had to enter it on separate lines. Kisses to you all!
 

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

Back
Top