Wrox Programmer Forums
|
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
 
Old October 19th, 2005, 09:16 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default 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

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

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
 
Old October 20th, 2005, 09:47 AM
Authorized User
 
Join Date: Aug 2005
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Dharam80
Default

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

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

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
 
Old October 20th, 2005, 12:51 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default

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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.