How do I get a parameter query to run with all or part of a criter

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

Guest

I have a query with the criteria [Last Name]. It prompts us enter the last
name. However, If I type Adams, and the last name is Adams Lovett, it won't
bring up the entry. I would like to form a query that pulls up any entry
with any or part of the last name that I type in. I am using Access 2003.
 
I have a query with the criteria [Last Name]. It prompts us enter the last
name. However, If I type Adams, and the last name is Adams Lovett, it won't
bring up the entry. I would like to form a query that pulls up any entry
with any or part of the last name that I type in. I am using Access 2003.

As criteria on the [LastName] field:

Like "*" & [What Name] & "*"
 
Fred,

I found this very useful and clicked the button to indicate as much. I
recently used this in a query and it works like a charm.

However I have one quick question: Is there any way to make this work by
only identifying those last names that START with the letters entered?

For instance, by using your suggestion below, if I enter RAN into my query
parameter I not only get back RANdall and RANkin, but also bRANdon, etc. I
only want to locate Randall and Rankin.

Thanks,
Nicole



fredg said:
I have a query with the criteria [Last Name]. It prompts us enter the last
name. However, If I type Adams, and the last name is Adams Lovett, it won't
bring up the entry. I would like to form a query that pulls up any entry
with any or part of the last name that I type in. I am using Access 2003.

As criteria on the [LastName] field:

Like "*" & [What Name] & "*"
 
However I have one quick question: Is there any way to make this work by
only identifying those last names that START with the letters entered?

You might do well to read the Help file on "Wildcards" and "Like". The
criterion

Like "*" & [What Name] & "*"

puts an asterisk ("Match any string of characters") before and after
the prompt. If you want to have wildcard characters only after the
prompt, simply remove the first asterisk:

Like [What Name] & "*"

John W. Vinson[MVP]
 
Thank you very much, John! I will be sure to check out the suggested help
files!

-Nicole

John Vinson said:
However I have one quick question: Is there any way to make this work by
only identifying those last names that START with the letters entered?

You might do well to read the Help file on "Wildcards" and "Like". The
criterion

Like "*" & [What Name] & "*"

puts an asterisk ("Match any string of characters") before and after
the prompt. If you want to have wildcard characters only after the
prompt, simply remove the first asterisk:

Like [What Name] & "*"

John W. Vinson[MVP]
 
Back
Top