Problem with Multiple OR

  • Thread starter jc.vega via AccessMonster.com
  • Start date
J

jc.vega via AccessMonster.com

I am trying get a result using the following WHERE statement, which doesn't
work - or should I say, doens't give the correct result.

WHERE Fields.fLabsCutoff<#12/18/2006# And (Fields.fCBC=Yes) And (Fields.
fCBCReceived=No) OR (Fields.fChem7=Yes) And (Fields.fChem7Received=No) OR
(Fields.fXRAY=Yes) and (Fields.fXRAYReceived=No);

If I do the following it works fine:

WHERE Fields.fLabsCutoff<#12/18/2006# And (Fields.fCBC=Yes) And (Fields.
fCBCReceived=No);

Any help given is much appreciated.
 
D

Douglas J. Steele

What exactly are you looking for? And has a higher precedence than Or. You
might need to include some parentheses:

WHERE (Fields.fLabsCutoff<#12/18/2006# And (Fields.fCBC=Yes) And
(Fields.fCBCReceived=No))
OR ((Fields.fChem7=Yes) And (Fields.fChem7Received=No))
OR ((Fields.fXRAY=Yes) and (Fields.fXRAYReceived=No))

That will retrieve rows where the first line is true or the second line is
true or the third line is true.
 
J

jc.vega via AccessMonster.com

Basically there are 10 checkbox controls on my form one to check if something
was sent and one to check if it was received. I needed a query that will show
every record that has a check on Sent and not one received, by a specific
date.

Adding the parentheses didn't help. I actually have tried it every which way
I could think of.

Anyone else have any ideas?

What exactly are you looking for? And has a higher precedence than Or. You
might need to include some parentheses:

WHERE (Fields.fLabsCutoff<#12/18/2006# And (Fields.fCBC=Yes) And
(Fields.fCBCReceived=No))
OR ((Fields.fChem7=Yes) And (Fields.fChem7Received=No))
OR ((Fields.fXRAY=Yes) and (Fields.fXRAYReceived=No))

That will retrieve rows where the first line is true or the second line is
true or the third line is true.
I am trying get a result using the following WHERE statement, which doesn't
work - or should I say, doens't give the correct result.
[quoted text clipped - 9 lines]
Any help given is much appreciated.
 
J

John Spencer

Parentheses are your friend.

WHERE Fields.fLabsCutoff<#12/18/2006# And
(
(Fields.fCBC=Yes And Fields.fCBCReceived=No)
OR (Fields.fChem7=Yes And Fields.fChem7Received=No)
OR (Fields.fXRAY=Yes and Fields.fXRAYReceived=No)
)

By the way, strange name for a table - Fields
 
J

jc.vega via AccessMonster.com

John, thank you. You are right, Parentheses are my friend now. It worked
great!

Yeah, I agree the naming structure is strange. However it's too late to go
back and change everything.

Thanks again.

John said:
Parentheses are your friend.

WHERE Fields.fLabsCutoff<#12/18/2006# And
(
(Fields.fCBC=Yes And Fields.fCBCReceived=No)
OR (Fields.fChem7=Yes And Fields.fChem7Received=No)
OR (Fields.fXRAY=Yes and Fields.fXRAYReceived=No)
)

By the way, strange name for a table - Fields
I am trying get a result using the following WHERE statement, which doesn't
work - or should I say, doens't give the correct result.
[quoted text clipped - 9 lines]
Any help given is much appreciated.
 
Top