Division by zero.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
F

Frank Martin

I have a control on a report to give me a unit cost and this involves the
expression "=[Text19]/Val([Unit])".

This to extract the numerical part of a field so this can be the divisor to
give me a single or unit cost.

The expression takes the value of 200Kg as '200', and 25L as '25' etc, but
unfortunately takes the value of Kg as "0" instead of "1".

Is there any way to make the system recognize "Kg" or "L" as 1 and not 0.

Please help, Frank
 
=Text19/IIf(Val([Unit])=0,1,Val([Unit]))
BTW: Do everyone (especially yourself) a favor and rename Text19 to
something that is understandable.
 
Frank said:
I have a control on a report to give me a unit cost and this involves the
expression "=[Text19]/Val([Unit])".

This to extract the numerical part of a field so this can be the divisor to
give me a single or unit cost.

The expression takes the value of 200Kg as '200', and 25L as '25' etc, but
unfortunately takes the value of Kg as "0" instead of "1".

Is there any way to make the system recognize "Kg" or "L" as 1 and not 0.


Just check the denominator and don't do the division if it's
zero:
=IIf(Val(Unit) = 0, Text19, Text19 / Val(Unit))
 
Back
Top