IF Statement Error

Joined
Aug 13, 2011
Messages
1
Reaction score
0
I am trying to use an if statement combined with a DateDiff statement in Access. I want to the see the following if textbox1 = yes, then calculated the aging date. Here is what i have written, keep getting invalid syntax error. Please help. Thankyou

=IIF([CloseoutOverDue]=''yes'',DateDiff("d",[CloseoutDue],Now())). Same thing is written in the control source of the property sheet.
 
Hi lvwilliams,

I haven't touched Access in a while, so hard to remember the correct syntax.

However if Access has the same syntax as Excel, it seems that you are missing a parameter in the IF function.

in Excel the IF function has 3 parameters:
- The condition (in your example: [CloseoutOverDue]=''yes'')
- The result/output if the condition is met: DateDiff("d",[CloseoutDue],Now())
- The result/output if the condition is not met: if like excel you may be missing this part or may have put a closing bracket at the wrong place.

it looks like you wanted to achieve the following:

- The condition (in your example: [CloseoutOverDue]=''yes'')
- The result/output if the condition is met: DateDiff("d",[CloseoutDue])
- The result/output if the condition is not met: Now()

which results in the following formula: =IIF([CloseoutOverDue]=''yes'',DateDiff("d",[CloseoutDue]),Now())

Let me know if the above has helped. Thanks

Sifou
 
Back
Top