Wrox Programmer Forums Division by zero error
 |
 Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
 Welcome to the p2p.wrox.com Forums. You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com

October 19th, 2005, 09:16 PM
 Corey Friend of Wrox Join Date: Sep 2005 Posts: 106 Thanks: 0 Thanked 0 Times in 0 Posts
Division by zero error

Iâm having trouble with a Division by zero error.

Iâm trying to take to do the following:

the quantity canceled to date: âOL_QTY_CAN_TDâ divide it by the quantity ordered âOL_QTY_ORDâ

The formula below is what I thought would be to get around the Division by zero error.

Please let mw know what Iâm doing wrong.

Canceled: Iif(Nz([OL_QTY_CAN_TD],0) <> 0, ([OL_QTY_CAN_TD]/[OL_QTY_ORD]), 0)

Thanks

Corey

October 19th, 2005, 10:14 PM
 echovue Friend of Wrox Join Date: Oct 2004 Posts: 564 Thanks: 0 Thanked 4 Times in 4 Posts

Hi Corey,

I am thinking what you want to do is do the initial test on the denominator (OL_QTY_ORD), if that guy is 0 that would cause the division by zero error, whereas the other would just equal zero.

Hope that helps,

Mike

Mike
EchoVue.com

October 20th, 2005, 09:47 AM
 Dharam80 Authorized User Join Date: Aug 2005 Posts: 42 Thanks: 0 Thanked 0 Times in 0 Posts

try this one: IIf([OL_QTY_ORD]=0,0,([OL_QTY_CAN_TD]/[OL_QTY_ORD]))

Dharmesh Bhavsar

October 20th, 2005, 11:18 AM
 echovue Friend of Wrox Join Date: Oct 2004 Posts: 564 Thanks: 0 Thanked 4 Times in 4 Posts

That would work, but you would need to put add the Nz Function, incase OL_QTY_ORD is null.

IIf(Nz([OL_QTY_ORD])=0,0,([OL_QTY_CAN_TD]/[OL_QTY_ORD]))

Mike
EchoVue.com

October 20th, 2005, 12:51 PM
 Corey Friend of Wrox Join Date: Sep 2005 Posts: 106 Thanks: 0 Thanked 0 Times in 0 Posts

It worked!!!

Thanks Dharmesh and Mike

 Similar Threads Thread Thread Starter Forum Replies Last Post Division by zero Corey BOOK: Beginning Access 2003 VBA 2 April 13th, 2007 02:56 PM IIf Statement "division by zero" error Corey BOOK: Beginning Access 2003 VBA 5 September 30th, 2005 05:48 AM division by zero rickjg JSP Basics 1 November 9th, 2004 08:03 AM Performing Division in XSLT... Please help.. kiril XSLT 3 May 17th, 2004 05:27 AM Division by zero error ss2003 Beginning PHP 5 January 1st, 2004 11:51 AM