Like statement

H

hughess7

Hi all

I have an unbound control on a form called PartNo. In my query I have the
following criteria:

[forms]![frm Part Number Prices]![PartNo] Or Like "*forms![frm Part Number
Prices]![PartNo]*"

On the form I enter 1123 but the query does not return any records. If I
replace with [forms]![frm Part Number Prices]![PartNo] Or Like "*1123*"
instead this works and returns any records which has 1123 within the part
number value.

Is there a reason why I can't use a control or is this syntax incorrect?

Thanks
Sue
 
A

Allen Browne

Try concatenating the wildcards into the string:

Like "*" & [Forms]![frm Part Number Prices]![PartNo] & "*"
 
D

Douglas J Steele

First of all, there's no reason to have both criteria: the first is a
specific subset of the second (and both will always be executed, so there's
no efficiency to be gained if the complete string was input)

The problem with the second part of your criteria, though, is that you've
got everything inside of the quotes, so it's looking for a part number that
includes the literal string "forms![frm Part Number Prices]![PartNo]"
somewhere!

Try

Like "*" & forms![frm Part Number Prices]![PartNo] & "*"
 

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