Solved

MS Access Query - Nested IIF Statement isn't working

Posted on 2014-10-02
3
420 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 36

Accepted Solution

by:
PatHartman earned 300 total points
ID: 40357956
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
ID: 40358032
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
 
LVL 1

Author Comment

by:gdunn59
ID: 40358414
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

680 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