what's wrong?

A

antonov

Hello. Can anybody please tell me what's wrong with the following formula?:

=IIF(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",([Date],[Out])+1)*[ChargWeight])*0.015

I input it in the Control Source but I get all sorts of error messages....

thanks
 
B

Brendan Reynolds

You've got some excess parentheses in the second DateDiff call. Try this ...

=IIf(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",[Date],[Out]+1)*[ChargWeight])*0.015

It's possible that the parentheses might have been there for a reason (to
over-ride the default order of precedence) but were in the wrong position,
but if so I can't advise on what exactly would be the *right* position
without more information.
 
A

antonov

the result should be the daydiff (if <3 including Date and Out - if Date =
sept1 and Out= sept2 the difference should be 2, that is why +1 in the
formula) then the DateDiff * charg Weight and the result *0.015
Brendan Reynolds said:
You've got some excess parentheses in the second DateDiff call. Try this
...

=IIf(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",[Date],[Out]+1)*[ChargWeight])*0.015

It's possible that the parentheses might have been there for a reason (to
over-ride the default order of precedence) but were in the wrong position,
but if so I can't advise on what exactly would be the *right* position
without more information.

--
Brendan Reynolds (MVP)

antonov said:
Hello. Can anybody please tell me what's wrong with the following
formula?:

=IIF(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",([Date],[Out])+1)*[ChargWeight])*0.015

I input it in the Control Source but I get all sorts of error
messages....

thanks
 
B

Brendan Reynolds

I'm sorry, I'm afraid I didn't understand that.

--
Brendan Reynolds (MVP)

antonov said:
the result should be the daydiff (if <3 including Date and Out - if Date =
sept1 and Out= sept2 the difference should be 2, that is why +1 in the
formula) then the DateDiff * charg Weight and the result *0.015
Brendan Reynolds said:
You've got some excess parentheses in the second DateDiff call. Try this
...

=IIf(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",[Date],[Out]+1)*[ChargWeight])*0.015

It's possible that the parentheses might have been there for a reason (to
over-ride the default order of precedence) but were in the wrong
position, but if so I can't advise on what exactly would be the *right*
position without more information.

--
Brendan Reynolds (MVP)

antonov said:
Hello. Can anybody please tell me what's wrong with the following
formula?:

=IIF(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",([Date],[Out])+1)*[ChargWeight])*0.015

I input it in the Control Source but I get all sorts of error
messages....

thanks
 
A

antonov

ok, I will try to be more specific:

I have a form and in this form I have 4 text boxes (which I will call
fields). In the first field there should be a formula that reads:
=IIf(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",[Date],[Out]+1)*[ChargWeight]*0.015)
this works ok but.... it should work only if the date difference is up to 15
days because then...
field 2 should take over and calculate the whole difference at 0.03 and not
0.015.... over 30 days and up to 365 field 3 should take over at a rate of
0.050 and over 365 field 4 at a rate of 0.070. Catch 21: for all 4 fields a
min. of $3 (if date difference is >3) should apply.....




Brendan Reynolds said:
I'm sorry, I'm afraid I didn't understand that.

--
Brendan Reynolds (MVP)

antonov said:
the result should be the daydiff (if <3 including Date and Out - if Date
= sept1 and Out= sept2 the difference should be 2, that is why +1 in the
formula) then the DateDiff * charg Weight and the result *0.015
Brendan Reynolds said:
You've got some excess parentheses in the second DateDiff call. Try this
...

=IIf(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",[Date],[Out]+1)*[ChargWeight])*0.015

It's possible that the parentheses might have been there for a reason
(to over-ride the default order of precedence) but were in the wrong
position, but if so I can't advise on what exactly would be the *right*
position without more information.

--
Brendan Reynolds (MVP)

Hello. Can anybody please tell me what's wrong with the following
formula?:

=IIF(DateDiff("d",[Date],[Out])<=2,0,DateDiff("d",([Date],[Out])+1)*[ChargWeight])*0.015

I input it in the Control Source but I get all sorts of error
messages....

thanks
 
Top