Query criteria based on other field's value

  • Thread starter Thread starter John J.
  • Start date Start date
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
 
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.
 
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] & "*"
 
Thanks all. I accidentally tested on the wrong table. Finally:

Not Like [OtherFieldFromSameTable] & "*"

does the job.

John
 
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
 
Back
Top