Helpful friends,
I have a calculated field in a form that checks to see if the completion date is filled in. If not, it returns the CURRENT date minus the start date. If it is, it returns the COMPLETION date minus the start date.
Here is my (working) code for that:
Now I want to added the ability to suspend the study by entering Suspend and Resume dates. My new IIf statement includes several nested IIf's to account for the three possible conditions: Suspend Date, Resume Date and Completion Date. Here is the code I'm trying to use for this:
As you can see, a heck of a lot more complicated.
The problem is that when I try to save it, I get an error that the expression has "A function containing the wrong number of arguments."
I've gone through the code several times and everything seems to be in order. Each IIf has a Then condition and an Else condition. Everything is separated by commas and all the parentheses line up properly. (If anyone is really curious, I can e-mail you the Word file where I broke things up by line and colored coded things to try and find the error.)
One thing I wondered - this statement has 446 characters - is there a limit?
If this won't work as conceived, is there a better way to attack this? Maybe in VBA with an On Current or On Load routine?
Thanks, Rob
I have a calculated field in a form that checks to see if the completion date is filled in. If not, it returns the CURRENT date minus the start date. If it is, it returns the COMPLETION date minus the start date.
Here is my (working) code for that:
Code:
=IIf(IsNull([CompletionDate]),DateDiff("d",[DateReceived],Date()),DateDiff("d",[DateReceived],[CompletionDate]))
Now I want to added the ability to suspend the study by entering Suspend and Resume dates. My new IIf statement includes several nested IIf's to account for the three possible conditions: Suspend Date, Resume Date and Completion Date. Here is the code I'm trying to use for this:
Code:
=IIf(IsNull([CompletionDate]),IIf(IsNull([SuspendDate),DateDiff("d",[DateReceived],Date()),IIf(IsNull([ResumeDate]),DateDiff("d",[DateReceived],[SuspendDate]),DateDiff("d",[DateReceived],Date())-DateDiff("d",[SuspendDate],[ResumeDate]))),IIf(IsNull([SuspendDate),DateDiff("d",[DateReceived],[CompletionDate]),IIf(IsNull([ResumeDate]),”Need Resumption Date”,DateDiff("d",[DateReceived],[CompletionDate])-DateDiff("d",[SuspendDate],[ResumeDate]))))
The problem is that when I try to save it, I get an error that the expression has "A function containing the wrong number of arguments."
I've gone through the code several times and everything seems to be in order. Each IIf has a Then condition and an Else condition. Everything is separated by commas and all the parentheses line up properly. (If anyone is really curious, I can e-mail you the Word file where I broke things up by line and colored coded things to try and find the error.)
One thing I wondered - this statement has 446 characters - is there a limit?
If this won't work as conceived, is there a better way to attack this? Maybe in VBA with an On Current or On Load routine?
Thanks, Rob