Solved

Divisible by zero error

Posted on 2014-03-24
5
306 Views
Last Modified: 2014-03-24
I want the percent used section of the data to have this ----- instead of #Div/0 and or #Num if dividing by zero and below is the formula I am using.


%Used: Format(Nz([YTD],0)/Nz([AnnualBudget],0),"Percent")

Data

Budget      MTD      YTD      %Used

0.00      0.00      441,000.00      #Div/0!

0.00      0.00      0.00      #Num!

1,800.00      21.81      372.67      20.70%
0
Comment
Question by:Kdankwah
  • 3
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39950357
Since you are using the Format ( ) function, which returns a string, you could simply use:

%Used: IIF(NZ([AnnualBudget],0) = 0, "----", Format(Nz([YTD],0)/[AnnualBudget],"Percent"))
0
 

Author Comment

by:Kdankwah
ID: 39950370
Thanks so much
0
 

Author Comment

by:Kdankwah
ID: 39950371
What will be if I am using a formula that will return a number string.

Thanks
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39950848
you could still use the iif() function, but cannot embed a string in an otherwise numeric field, so something like:

iif(isnull([field name]), null, [other field]/[field name])
0
 

Author Comment

by:Kdankwah
ID: 39950904
thanks
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now