A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"Division by Zero" Question



 
 
Thread Tools Display Modes
  #1  
Old July 31st, 2009, 09:09 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default "Division by Zero" Question

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.
  #2  
Old July 31st, 2009, 09:29 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default "Division by Zero" Question

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

AccessIM wrote:
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.

  #3  
Old August 3rd, 2009, 03:29 PM posted to microsoft.public.access.queries
AccessIM
external usenet poster
 
Posts: 81
Default "Division by Zero" Question

Thank you, John! That worked great.

"John Spencer" wrote:

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

AccessIM wrote:
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.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.