Nested IIf & Error: "Text is too long to be edited"

C

croy

When I try to put my nested IIf statement into a query, I
get the "Text is too long to be edited" message.

Here's the text:

HrDivisor:
IIf(DatePart("h",[Start])=(DatePart("h",[Finish]),1,IIf(DatePart("n",[Start])=0
And DatePart("n",[Finish])=0,1 +
(DatePart("h",[Finish])-DatePart("h",[Start])-1),IIf(DatePart("n",[Start])=0,1
+
(DatePart("n",[Finish])/((60-DatePart("n",[Start]))+DatePart("n",[Finish]))
+
(DatePart("h",[Finish])-DatePart("h",[Start])-1),IIf(DatePart("n",[Finish])=0,((60-DatePart("n",[Start]))/(60-DatePart("n",[Start])+DatePart("n",[Finish])))
+
(DatePart("h",[Finish])-DatePart("h",[Start])),((60-DatePart("n",[Start]))/(60-DatePart("n",[Start])+DatePart("n",[Finish])))
+
(DatePart("n",[Finish])/((60-DatePart("n",[Start]))+DatePart("n",[Finish])))
+ (DatePart("h",[Finish])-DatePart("h",[Start])-1)))))



Is this really too much text, or do I have an error in there
somewhere?
 
G

Golfinray

An IIF statement can only be 2048 characters and that includes commas,
parenthesis and everything.
 
J

John W. Vinson

When I try to put my nested IIf statement into a query, I
get the "Text is too long to be edited" message.

Here's the text:

HrDivisor:
IIf(DatePart("h",[Start])=(DatePart("h",[Finish]),1,IIf(DatePart("n",[Start])=0
And DatePart("n",[Finish])=0,1 +
(DatePart("h",[Finish])-DatePart("h",[Start])-1),IIf(DatePart("n",[Start])=0,1
+
(DatePart("n",[Finish])/((60-DatePart("n",[Start]))+DatePart("n",[Finish]))
+
(DatePart("h",[Finish])-DatePart("h",[Start])-1),IIf(DatePart("n",[Finish])=0,((60-DatePart("n",[Start]))/(60-DatePart("n",[Start])+DatePart("n",[Finish])))
+
(DatePart("h",[Finish])-DatePart("h",[Start])),((60-DatePart("n",[Start]))/(60-DatePart("n",[Start])+DatePart("n",[Finish])))
+
(DatePart("n",[Finish])/((60-DatePart("n",[Start]))+DatePart("n",[Finish])))
+ (DatePart("h",[Finish])-DatePart("h",[Start])-1)))))

Could you explain in words what this is intended to accomplish? If you want to
display the duration from Start to Finish in hh:nn format, try instead:

DateDiff("h", [Start], [Finish]) & ":" & Format(DateDiff("n", [Start],
[Finish]) MOD 60, "00")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top