Solved

MS Access Query - Nested IIF Statement isn't working

Posted on 2014-10-02
3
412 Views
Last Modified: 2014-10-02
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
Comment
Question by:gdunn59
3 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 300 total points
Comment Utility
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
 
LVL 10

Assisted Solution

by:Gozreh
Gozreh earned 200 total points
Comment Utility
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
 

Author Comment

by:gdunn59
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now