IIF statement with an AND and an OR

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,690
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?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,783
Office Version
365
Platform
Windows
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)
 

Forum statistics

Threads
1,085,679
Messages
5,385,154
Members
401,935
Latest member
jgodonnell

Some videos you may like

This Week's Hot Topics

Top