Solved

MS Access Query - Nested IIF Statement isn't working

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

839 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