View Full Version : need help with LIKE Operator!


Essendon
10-25-2001, 06:29 PM
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

directormac
10-25-2001, 07:17 PM
By putting the control name inside double quotes, you're telling access to look for that STRING, rather than the value in the contorl. Try this:

Like ("*" & [Forms]![Criteria]![String] & "*")

Jack Cowley
10-25-2001, 07:19 PM
Like "*" & [Forms]![Query Dialog]![Name] & "*"

Essendon
10-25-2001, 07:25 PM
Thankyou very much for your help. It is greatly appretiated.

directormac
10-25-2001, 07:27 PM
You can tell it's late in the day here--my typing is shot and I'm no long switching my "test" field names back to the ones the other person used :O

Many thanks and great respect to Jack & Pat

--Sheepish Mac