Link to home
Start Free TrialLog in
Avatar of deer777
deer777Flag for United States of America

asked on

Need to calculate about 8 textboxes on a form by adding 4 and dividing by the sum of the other four

Need to calculate about 6 textboxes on a form by adding 4 and dividing by the sum of the other four

Some of the textboxes are blank and causing a #Num! error.  I am currently using this formula:

=CDbl(Nz((CDbl(Nz([vol1],0))+CDbl(Nz([vol2],0))+CDbl(Nz([vol3],0))/=CDbl(Nz([time1],0))+CDbl(Nz([time2],0))+CDbl(Nz([time3],0))+CDbl(Nz([time4],0))
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

you got extra = there?

=CDbl(Nz((CDbl(Nz([vol1],0))+CDbl(Nz([vol2],0))+CDbl(Nz([vol3],0))/=CDbl(Nz([time1],0))+CDbl(Nz([time2],0))+CDbl(Nz([time3],0))+CDbl(Nz([time4],0))

quick try:

=CDbl(Nz((CDbl(Nz([vol1],0))+CDbl(Nz([vol2],0))+CDbl(Nz([vol3],0))/CDbl(Nz([time1],0))+CDbl(Nz([time2],0))+CDbl(Nz([time3],0))+CDbl(Nz([time4],0)) 

Open in new window

you may also consider to put brackets in your calculation:

=( CDbl(Nz((CDbl(Nz([vol1],0))+CDbl(Nz([vol2],0))+CDbl(Nz([vol3],0)) ) / ( CDbl(Nz([time1],0))+CDbl(Nz([time2],0))+CDbl(Nz([time3],0))+CDbl(Nz([time4],0)) )
Avatar of deer777

ASKER

Sorry but I get #Num! and #Div/0! errors on both of the fixes above
Avatar of deer777

ASKER

Was getting sums on the ones that had numbers in them but #Num! errors on the blank textbox sums  (without the extra = in the calc)
Try using Val and Nz:

=(Val(Nz([vol1]))+Val(Nz([vol2]))+Val(Nz([vol3]))+Val(Nz([vol4]))) / (Val(Nz([time1]))+Val(Nz([time2]))+Val(Nz([time3]))+Val(Nz([time4])))

Open in new window

Avatar of deer777

ASKER

Still need help. . . have not solved this issue yet
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deer777

ASKER

Val and Nz give me the same result as with CDbl and Nz - I get sums on several and the ones that the sums are 0 on either the vol or time side, I get the #Num! error.  So the issue seems to be that I am getting an error on the division with 0 on either side (vol or time) with the #Num! error
That can't be true, as Val returns 0 for Nz(Null) and for any string. Also, the IIf divides be 1 if the sum of time is zero.

So something in your end is not as you think it is, like different naming of fields or controls. Also, the name of the control mut be different of any of the control uses in the calculation.
Avatar of deer777

ASKER

Gustav Perfection!!!

You solved it!!
Great!