Results 1 to 2 of 2

Thread: IIF statement with an AND and an OR

  1. #1
    Board Regular gheyman's Avatar
    Join Date
    Nov 2005
    Location
    Orlando, FL USA
    Posts
    1,665
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default IIF statement with an AND and an OR

    Is this correct?
    MONTH1_PDL: IIf(((DateDiff("m",[PDIR Due Date],Now()))>1) And ((DateDiff("m",[PDIR Completed],Now()))=<1) Or ([PDIR Completed] Is Null),1,0)


    I need the first condition met and only one of the next two to true

    [PDIR Due Date],Now()))>1 Needs to be True

    AND
    [PDIR Completed],Now()))=<1 OR ([PDIR Completed] Is Null Needs to be True

    Should the last two be enclosed in a bracket?
    G Heyman
    Northrop Grumman - Laser Systems'
    Apopka, FL

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    51,042
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Access: IIF statement with an AND and an OR

    Not quite. Try this:
    Code:
    MONTH1_PDL: IIf((DateDiff("m",[PDIR Due Date],Now())>1) And ((DateDiff("m",[PDIR Completed],Now())=<1) Or ([PDIR Completed] Is Null)),1,0)
    The trick is to write each condition separately, and comletely, and then just drop into the structure you need, i.e.
    IIF((condition1) And ((Condition2) Or (Condition3)),1,0)
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •