• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

MS Access Query - Nested IIF Statement isn't working

I have a MS Access Query that contains a Nested IIF Statement, but it doesn't appear to be working with the 2nd IIF Statement.

Here is the syntax I have:

Month3: IIf([thedate]>#10/1/2013#,UCase(MonthName([themonth],True)) & "_2014_AEP",IIf([thedate]>=#10/1/2014#,UCase(MonthName([themonth],True)) & "_2014_2015_AEP",""))

What am I doing wrong?

Thanks,
gdunn59
0
gdunn59
Asked:
gdunn59
2 Solutions
 
PatHartmanCommented:
You don't say what result you are getting but I can guess.

When you use an open ended condition such as > some date and you have multiple conditions, you must force them to be evaluated in descending order because  today's date for example 10/2/2014 is > both and so the first condition returns true and that's the end of that.
0
 
GozrehCommented:
The first IIF will overwrite the second like PatHartman explained, so you need to change them
Month3: IIf([thedate]>=#10/1/2014#,UCase(MonthName([themonth],True)) & "_2014_2015_AEP",IIf([thedate]>#10/1/2013#,UCase(MonthName([themonth],True)) & "_2014_AEP",""))

Open in new window

0
 
gdunn59Author Commented:
Gozreh:

That worked great:

Month3: IIf([thedate]>=#10/1/2014#,UCase(MonthName([themonth],True)) & "_2014_2015_AEP",IIf([thedate]>#10/1/2013#,UCase(MonthName([themonth],True)) & "_2014_AEP",""))

Thanks,
gdunn59
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now