Expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Teri B
    New Member
    • Mar 2022
    • 4

    Expression

    I am trying to write an expression and having trouble. I get the first part of my arguments correct but when I try to add the third I run into trouble. Here is the first part of the expression:
    Code:
    =IIf([completedate]>"",
       "Complete",
       IIf(
          IsNull([CompleteDate]) And ([DueDate]<Date()),
          "Overdue",
          ""
       )
    )
    This works correctly. When I try and add the last bit it does not work. Here is what I am trying to add

    IIf([ReviewDate]<= Date(),"In Process","")

    Can anyone help me.
    Last edited by zmbd; Apr 16 '22, 06:27 PM. Reason: [z{placed required code tags and stepped the posted code}]
  • cactusdata
    Recognized Expert New Member
    • Aug 2007
    • 223

    #2
    Try with:

    Code:
    =IIf(Not [CompleteDate] Is Null,
        "Complete",
        IIf([ReviewDate] <= Date(), 
            "In Process",
            IIf([DueDate] < Date()
                "Overdue",
                Null)))

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      @Teri B
      When writing nested IIF() functions I usually start out by creating the skeleton code
      (would you post back which database you're using)
      Code:
      [iCODE]Start with the outer IIF - notice the stepping of the code [/iCODE]
      [iCODE]stepping your code will help keep things straight in you mind[/iCODE]
      IIF(condition, 
         true, 
         false
      )
      [iCODE]Now add the inner IIF(); in this example an on false [/iCODE]
      IIF(condition, 
         true, 
         IIF(condition2
            true,
            false
         )
      )
      [iCODE]at this point keep adding and stepping[/iCODE]
      [iCODE]- say I want a on true for the 3rd[/iCODE]
      IIF(condition, 
         true, 
         IIF(condition2
            IFF(condition3, 
               true, 
               false
            ),
            false
         )
      )
      
      [iCODE]quite often in VBA I'll comment the code as I go; unfortunately,[/iCODE]
      [iCODE]most SQL will not let you add comments[/iCODE]
      IIF(condition1,
         'on true event condition1 
         true, 
         'on false event condition1 
         IIF(condition2
              'on true event condition2 
            IFF(condition3,
              'on true event condition3
               true, 
              'on false event condition3
               false
            ),
            'on false event condition2
            false
         )
      )
      [iCODE]From this point, now that the skeleton is laid out, [/iCODE]
      [iCODE]insert your true and false actions at each branch [/iCODE]
      [iCODE]within the nested functions[/iCODE]
      Last edited by zmbd; Apr 16 '22, 06:54 PM.

      Comment

      Working...