Nested IF Statements

Posted on 2011-04-20
Last Modified: 2013-11-05
I'm unable to execute the query below. Is there a limit on nested IF's? I get the error "Expression is too complex".

iif(Delivery_Status = ' ' or Delivery_Status is null,'Missing Data'
      ,iif(Expected_Date < Ready_Date,'Bad Settings'
            ,iif(Create_Date > Order_Date,'Bad Entry'
                  ,iif((abs(actual_days - sys_days)>1)
                        ,iif(Loc <> Primary_Loc,'Bad Loc'
                              ,iif(used_type <> Primary_Type,'Bad Type'
                                    ,iif(hours>48,'Too long'
                                          ,iif(Actual_Pickup_Date <> Sched_Pickup_Date and Actual_Pickup_Date is not null and Sched_Pickup_Date is not null
                                                ,iif(Actual_Pickup_Date < Sched_Pickup_Date,'Early Pickup'
                                                      ,'Late Pickup'
                                                ,iif((actual_days - sys_days)<-1, 'Fast Transit'
                                                      ,iif((actual_days - sys_days)>1,'Slow Transit','Unknown')
                        ,iif(actual_days < sys_days,'Fast Transit'
                              ,iif(actual_days > sys_days, 'Slow Transit','Unknown')
Question by:Lulu0
    1 Comment
    LVL 13

    Accepted Solution


    Most, if not all, versions of MS-Access have a nesting limit of 7.  The limit also applies to some other operations like function call nesting.

    I would suggest taking a look at the logic and see if it can be simplified.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now