Maximum number of nested IIf() statements in an expression

  • Thread starter Thread starter Ann Scharpf
  • Start date Start date
A

Ann Scharpf

I've looked through help and this board and can't seem to find this answer.
Is there a maximum number of IIf statements you can string in a single
expression?

As always, thanks for your help.
 
I've looked through help and this board and can't seem to find this answer.  
Is there a maximum number of IIf statements you can string in a single
expression?

As always, thanks for your help.

FWIW, when I have insane nested if statements, I usually resort to
using an indexed junction table instead.
 
Lord Kelvan said:
10 i beleave i heard


I couldn't find it in the documentation either, so I tried a quick test. Ten
does indeed appear to be the limit. I tested by starting with a simple
expression in a query ...

Test: IIf(True, True, False)

I then copied the entire IIf() statement, selected the word False, and
pasted in the copied statement ...

Test: IIf(True, True, IIf(True, True, False))

.... and continued selecting the world False and pasting until I had ten
levels of nested IIf() statements ...

Test:
IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,IIf(True,True,False))))))))))

This statement was executed without error, but the addition of one more
level resulted in the error "the expression you entered contains invalid
syntax".
 
Hmm. That's interesting. I ended up deciding I was being a wuss and tried
myself. I was able to use 13 nested IIfs and on 14 my error was different.
Mine said the expression was too complex.

I'm running Access 2003. What version are you running?

And thanks for responding!
 
Ann Scharpf said:
Hmm. That's interesting. I ended up deciding I was being a wuss and
tried
myself. I was able to use 13 nested IIfs and on 14 my error was
different.
Mine said the expression was too complex.

I'm running Access 2003. What version are you running?


I'm constantly switching between 2007 and 2003, and I'm afraid I can't
remember for sure now which one I used for that test. It was probably 2007.
 
Back
Top