Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with the LIKE operator!

Status
Not open for further replies.

essendon

IS-IT--Management
Jun 1, 2004
4
AU
Hi all,
Could anyone explain why the following LIKE statement:

Like "*adam*"

works well, on a single name field that includes first name and last name, returning results such as:
Adams Dane
Wright Adam
Thornber Adam
Adamson Geoff

But when I try to get user input (instead of using adam) from a form:

Like "*[Forms]![Query Dialog]![Name]*"

(name is a text field on the Query Dialog Form)

It wont work at all!

What changes to the above code need to be made to make it work like the first example?

I would appreciate any help...Thanks in advance,

Peter
 
Code:
 Like "*" & [Forms]![Query Dialog]![Name] & "*"

When you put the field name between the single quotes, Access is looking for that actual string: bracket, letter F, letter O, letter R, etc...

Using the above identifies the wildcards as strings and the field reference as a field reference.


HTH
John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top