Solved

Help with #Num!  error on a report

Posted on 2001-07-02
8
274 Views
Last Modified: 2012-05-04
When I use a calculated field on a report and it is dividing a number by zero, it produces an error #Num! in the field on the report.
Is there a way to have it produce the answer whenever it is legit, but replace the #Num! with 0 or anything I decide.
I was thinking maybe IIF ?

Thanks

Bill
0
Comment
Question by:bmeehan
  • 5
  • 2
8 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6245908
here is an example of that:

field3: IIf([field2]=0;"0";[field1]/[field2])

cheers
Ricky
0
 
LVL 8

Expert Comment

by:dovholuk
ID: 6245930
paurths is on the money (not sure about those semi-colons though?)

i would change it around a bit to accept NULL values as well. such as:

CalculatedField : IIF(Nz(AFieldThatCouldBeZero,0) = 0, 'INF', SomeOtherField / AFieldThatCouldBeZero)

just adding to paurths comment...

dovholuk
0
 

Author Comment

by:bmeehan
ID: 6245959
I tried this:
=IIf([SumOfmay margin]/[SumOfmay amt]=0," ",[SumOfmay margin]/[SumOfmay amt])

and the answer is either the correct amt or I get a #Num!

I notice it is when both margin and amt = 0
Could it have something like division by 0 is not allowed?

Bill
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 12

Accepted Solution

by:
Paurths earned 50 total points
ID: 6245980
=IIf([SumOfmay amt]=0," ",[SumOfmay margin]/[SumOfmay amt])
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6245989
u checked the division in the iif statement to a 0 value.
if sumofmay amt is yet zero then u have #num result, so it is not 0 and the true part of the iif statement is not shown. Only the false.
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6245991
btw, exactly, division by zero can not be processed.
0
 
LVL 12

Expert Comment

by:Paurths
ID: 6246008
or checking for null values also (dovholuk)
=IIf(Nz([sumOfMay amt];0)=0;" ";[SumOfMay margin]/[SumOfMay amt])
0
 

Author Comment

by:bmeehan
ID: 6246153
That's it!

Thanks for the help.

Bill
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access Query on CSV returning number not text 6 36
Access 2016 Query with Proper Case logic 2 34
IIF in access query 19 24
modifying sql to include addl criteria 11 18
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question