"Division by Zero" Question

  • Thread starter Thread starter AccessIM
  • Start date Start date
A

AccessIM

I have a calculated field shown below:

CasesReplenished: (([Item_Pack]*[ActQty])/[Vendor_Pack])

The field works great and the calculation is correct but, when I try to sort
by this field, I receive a "Division by zero" error.

Can someone tell me why this is and how I can sort by this field?

Thank you so much.
 
As a guess, in at least one place Vendor_Pack is zero.

Try changing your expression to
CasesReplenished: IIF(Vendor_Pack=0,Null,(([Item_Pack]*[ActQty])/[Vendor_Pack]))

Or if you want a different calculation then
CasesReplenished:
IIF(Vendor_Pack=0,[ActQty],(([Item_Pack]*[ActQty])/[Vendor_Pack]))


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Thank you, John! That worked great.

John Spencer said:
As a guess, in at least one place Vendor_Pack is zero.

Try changing your expression to
CasesReplenished: IIF(Vendor_Pack=0,Null,(([Item_Pack]*[ActQty])/[Vendor_Pack]))

Or if you want a different calculation then
CasesReplenished:
IIF(Vendor_Pack=0,[ActQty],(([Item_Pack]*[ActQty])/[Vendor_Pack]))


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
I have a calculated field shown below:

CasesReplenished: (([Item_Pack]*[ActQty])/[Vendor_Pack])

The field works great and the calculation is correct but, when I try to sort
by this field, I receive a "Division by zero" error.

Can someone tell me why this is and how I can sort by this field?

Thank you so much.
 
Back
Top