A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query criteria based on other field's value



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2009, 03:01 PM posted to microsoft.public.access
John J.
external usenet poster
 
Posts: 160
Default Query criteria based on other field's value

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


  #2  
Old March 1st, 2009, 03:23 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Query criteria based on other field's value

NOT LIKE "*" & [OtherFieldFromSameTable] & "*"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"John J." wrote in message
...
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


  #3  
Old March 1st, 2009, 03:24 PM posted to microsoft.public.access
Danny J. Lesandrini
external usenet poster
 
Posts: 263
Default Query criteria based on other field's value

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.
--
Danny J. Lesandrini

www.amazecreations.com


"John J." wrote ...
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



  #4  
Old March 1st, 2009, 03:27 PM posted to microsoft.public.access
Allen Browne
external usenet poster
 
Posts: 11,706
Default Query criteria based on other field's value

Try:
Not Like [OtherFieldFromSameTable] & "*"

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John J." wrote in message
...
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?


  #5  
Old March 1st, 2009, 03:28 PM posted to microsoft.public.access
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Query criteria based on other field's value

On Sun, 01 Mar 2009 16:01:29 +0100, John J. wrote:

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] & "*"


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
  #6  
Old March 1st, 2009, 03:46 PM posted to microsoft.public.access
John J.
external usenet poster
 
Posts: 160
Default Query criteria based on other field's value

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

Not Like [OtherFieldFromSameTable] & "*"

does the job.

John


"John J." schreef in bericht
...
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



  #7  
Old March 1st, 2009, 06:33 PM posted to microsoft.public.access
emilybalise@yahoolcom
external usenet poster
 
Posts: 10
Default Query criteria based on other field's value


"John J." wrote in message
...
Thanks all. I accidentally tested on the wrong table. Finally:

Not Like [OtherFieldFromSameTable] & "*"

does the job.

John


"John J." schreef in bericht
...
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




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.