Limits on OR conditions in calculated fields?

  • Thread starter Thread starter TA Bran via AccessMonster.com
  • Start date Start date
T

TA Bran via AccessMonster.com

Hello all,

I'm having a problem with a calculated field in one of my queries. The
trouble seems to be coming from the number of OR conditions in the
expression evaluated in an IIf statement. The statement is returning a "1"
,or true, value even in records where the expression is clearly untrue.
The problem seems to go away if I reduce the number or OR conditions in th
IIf expression which has lead me to believe that there is some sort of
limit to the number of OR conditions allowed. Is this true or am I missing
something? I've posted the contents of the querie's field below:

CountOpen: IIf([ComboStatus]<>"127" Or "128" Or "129" Or "120" Or "131" Or
"132" Or "133" Or "134" Or "136" Or "137",1,Null)

If there is a limit to the number or ORs allowed, does anyone have a
suggestion of how I might otherwise accomplish the same thing? (I'm afraid
changing the expression to an = statement would require even more ORs)

Any assistance would be greatly appreciated.

-TA
 
Your expression will never be untrue, because it will be evaluated as
follows:

Iff (ComboStatus <> "127") Or ("128" <> False) Or ("129" <> False) etc.,
etc.

Of course, "128" will never be equal to False, so the expression will always
be True.

An expression using "Or" would need to looks something like ...

IIf((ComboStatus <> "127") Or (ComboStatus <> "128") Or etc., etc.

Alternatively, you may be able to come up with a simpler expression using
the Choose() or Switch() functions.
 
Brendan,

Thanks so much for pointing out my oversight and for your suggestions for
improvement. I've made the necesssary changes and its working perfectly
now.

All the best,

TA
 
Back
Top