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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

using the Or criteria



 
 
Thread Tools Display Modes
  #1  
Old July 8th, 2008, 05:32 PM posted to microsoft.public.access.queries
Barbara
external usenet poster
 
Posts: 306
Default using the Or criteria

I have a query that in addition to the name and address fields has 4 fields
named using iif statements. I need criteria to select names based on a "Yes"
entry in any of these 4 fields.

I have tried putting " " in the criteria field in Field 1 and the same in
the "or" field of Fields 2-4 and the result is names that are "yes" in Field
1 and some variety of 2-4.
  #2  
Old July 8th, 2008, 06:37 PM posted to microsoft.public.access.queries
Michel Walsh
external usenet poster
 
Posts: 2,404
Default using the Or criteria

It is probably easier to edit the criteria in the SQL view. Spot the WHERE
clause and instead of:

WHERE field1 0 AND field2 0

try


WHERE field1 0 OR ( field2 0 AND field3 0)


note that you can use parenthesis to specify the order of evaluation.

Also, it is preferable to use " 0" and "= 0" to say "is true" and
"is false", since 0 is false, and anything else, not null, is true.


Vanderghast, Access MVP


"Barbara" wrote in message
...
I have a query that in addition to the name and address fields has 4 fields
named using iif statements. I need criteria to select names based on a
"Yes"
entry in any of these 4 fields.

I have tried putting " " in the criteria field in Field 1 and the same
in
the "or" field of Fields 2-4 and the result is names that are "yes" in
Field
1 and some variety of 2-4.



  #3  
Old July 8th, 2008, 07:28 PM posted to microsoft.public.access.queries
Klatuu
external usenet poster
 
Posts: 7,074
Default using the Or criteria

SELECT SomeField FROM TableName WHERE [Field1] + [Field2] + [Field3] +
[Field4] 0

This assumes the Field1 - Field4 are Yes/No (Boolean) data types. No
(False) returns 0 and Yes(True) returns -1. If any one of the fields is
True, then a non zero value will be returned.
--
Dave Hargis, Microsoft Access MVP


"Barbara" wrote:

I have a query that in addition to the name and address fields has 4 fields
named using iif statements. I need criteria to select names based on a "Yes"
entry in any of these 4 fields.

I have tried putting " " in the criteria field in Field 1 and the same in
the "or" field of Fields 2-4 and the result is names that are "yes" in Field
1 and some variety of 2-4.

 




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 07:44 PM.


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