Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access Query - Nested IIF Statement isn't working

Posted on 2014-10-02
3
Medium Priority
?
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
PatHartman earned 1200 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 800 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

688 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