473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Query "Division by Zero" problem

DJRhino1175
221 128KB
Expand|Select|Wrap|Line Numbers
  1. Scrap%: IIf([BadParts]=0,0,Nz([BadParts]/[GoodParts]))
My issue is when I select Ascending or add some sort of filter in design view, then run it I get a pop up msgbox that says "Division By Zero". I need to build reports of of this query with different filters and cannot get them to run because of this.

Please help.

Thank you so very much in advance for any help I recieve.
Jul 18 '18 #1

✓ answered by Rabbit

It's the good parts that can't be 0, not bad parts.

Edit: But also, are you trying to calculate percentage? Or ratio? If you're trying to calculate percentage, it should be bad parts divided by the sum of bad parts and good parts.

5 1261
Rabbit
12,516 Expert Mod 8TB
It's the good parts that can't be 0, not bad parts.

Edit: But also, are you trying to calculate percentage? Or ratio? If you're trying to calculate percentage, it should be bad parts divided by the sum of bad parts and good parts.
Jul 18 '18 #2
PhilOfWalton
1,430 Expert 1GB
Hi Kevin

I thought we had dealt with this some months ago.

As Rabbit says you must ensure that GoodParts is not Null or Zero

Expand|Select|Wrap|Line Numbers
  1. Scrap%: IIf(Nz([GoodParts]) <> 0, Nz([BadParts])/[GoodParts], ???)
  2.  
Where I have got ??? you can either substitute 0 or omit the final comma & ??? to show a blank

Phil
Jul 18 '18 #3
DJRhino1175
221 128KB
Thanks Rabbit and Phil, that seemed to fix it(So far).

Phil,

We did, but once I started to build a report off of the query I was getting this error. Never thought having it backwards like that would make a difference, as it was working on the form...

Again thanks for the gentle smack upside the head.
Jul 18 '18 #4
twinnyfo
3,653 Expert Mod 2GB
It is also often helpful to make sure your numbers are never Null, if you intend to do any calculations on them. If you are performing a Count() on either your GoodParts or BadParts, those values should never be Null, as a Count() will always return 0 if there are no records matching your criteria. This can be helpful. Then you only have to worry about catching the Divide By Zero in your final calculations.

Just something to think about as you move forward.
Jul 18 '18 #5
NeoPa
32,556 Expert Mod 16PB
I can certainly say I've fallen over that one in the past.

Well caught Rabbit & Phil. I've selected Rabbit's as BA as it was on the money and the first reply.
Jul 19 '18 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dragan | last post by:
How can I save the height of query dataheet ? When I vertically resize query datasheet and save this size (height), it remains the same (default size) when I open it again. . In odlder verison...
2
by: Derek Davlut | last post by:
I have a make table query that I make a table from. I want the rows to continue increasing but it overwrites the data each time. I am gathering data from a linked source and to collect statistical...
2
by: Betrock | last post by:
This is probably very simple, but I just can't see my way thru it..... Short version: keyed values(numeric)in a lookup table are stored in a main table. They are displayed as text values - the...
2
by: Bob | last post by:
Hi Everybody I have a table called tblListingInbox which is connected to my MS Outlook InboxFolder This is the underlying table for a query called: qryListingConfirmed In...
0
by: Mark Fannon | last post by:
I created a database in SQL Server 2k which has a datetime field with only time info in it. When I create a parameter query in Access '02 to execute against that database and prompt for Start and...
3
by: dskillingstad | last post by:
I'd appreciate any help I can get. I'm not sure what I'm doing wrong, but.... I've searched these groups for some solutions but no luck. I have an unbound form (frmSearch), with several unbound...
10
by: Ken | last post by:
I have a form, that when I open it, it shows all items that are due for inspection in the current month and that is overdue. This is shown in continuous view and it has a column that shows overdue...
31
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I...
1
by: freddylocks | last post by:
Hi Everyone. I have a question regarding a Mysql query I am trying to run. I have 2 tables. Table 1: I have a column called FN which I hope to link to another table. At present the column...
5
by: PHPBABY3 | last post by:
Hi, 1. I have two SQL tables. I will call them employees and departments: EMP: LAST_NAME, FIRST_NAME, DEPTNM DEPT: NUM, NAME Input: text string FIND Output: the LAST_NAME, FIRST_NAME...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.