Query criteria based on other field's value

J

John J.

The following criteria in a query works: Not Like "testvalue*"

Now, I would like to substitute testvalue for the value of another field
from the same table, something like:
Not Like "[OtherFieldFromSameTable]*"

Obviously this doesn't work as the portion after Like is seen as a string.

Is it possible to create such a criteria?

Thank you.
John
 
D

Danny J. Lesandrini

I'm not sure what you're asking.

First, the criteria NOT LIKE "testvalue" is the same as <> "testvalue"
since there are no wildcards included.

Second, you *can* use a field in place of the literal value, like this ...

NOT LIKE "*" & [OtherField] & "*"

Add the wildcards in quotes and ampersand them to the field in brackets.
I don't see why that won't work for you.
 
R

Rick Brandt

The following criteria in a query works: Not Like "testvalue*"

Now, I would like to substitute testvalue for the value of another field
from the same table, something like:
Not Like "[OtherFieldFromSameTable]*"

Obviously this doesn't work as the portion after Like is seen as a
string.

Is it possible to create such a criteria?

Not Like [OtherFieldFromSameTable] & "*"
 
J

John J.

Thanks all. I accidentally tested on the wrong table. Finally:

Not Like [OtherFieldFromSameTable] & "*"

does the job.

John
 
E

emilybalise@yahoolcom

John J. said:
Thanks all. I accidentally tested on the wrong table. Finally:

Not Like [OtherFieldFromSameTable] & "*"

does the job.

John


John J. said:
The following criteria in a query works: Not Like "testvalue*"

Now, I would like to substitute testvalue for the value of another field
from the same table, something like:
Not Like "[OtherFieldFromSameTable]*"

Obviously this doesn't work as the portion after Like is seen as a
string.

Is it possible to create such a criteria?

Thank you.
John
 

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