PC Review


Reply
Thread Tools Rate Thread

IF Statement Error

 
 
New Member
Join Date: Aug 2011
Posts: 1
 
      13th Aug 2011
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.
 
Reply With Quote
 
 
 
 
Member
Join Date: May 2011
Location: London (UK)
Posts: 28
 
      23rd Aug 2011
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement into if statement in an event code (syntax error =?Utf-8?B?dG90YQ==?= Microsoft Access VBA Modules 1 12th Dec 2004 12:13 PM
vba: How do I write a "For Each Statement" nested in a "With Statement"? Mcasteel Microsoft Excel Programming 1 8th Nov 2004 10:23 PM
vba: How do I write a "For Each Statement" nested in a "With Statement"? Mcasteel Microsoft Excel Programming 0 8th Nov 2004 09:58 PM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 19th May 2004 02:41 AM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 17th May 2004 08:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:49 AM.