#Error

G

Guest

I am working on a perodicals database that holds usage statistics. I am
using the following code to calculate the cost per use, by dividing the cost
by the use. However if the use value is 0, the cost per use is displayed as
#Error. How can I rid of this error message and just have a zero value
displayed.

See below the SQL statements used to code this query:

SELECT Listings.Title, Listings.Cost, Listings.Use, [cost]/[use] AS [Cost
per Use], Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;

Any help with this problem is grately appreciated.

Sincerely,

Tiffany Miller
 
J

John Spencer (MVP)

Use an IIF function in the query. I might also use the NZ (Null to Zero)
function to force a zero value for the null.

SELECT Listings.Title, Listings.Cost, Listings.Use,
IIF(Nz([Use],0)>0,[cost]/[use],0) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

#Error Message 3
Creating a Keyword Query 3
errors in report 1
No Current Record Query Error 2
Divide by Zero Error 2
CrossTab Help! 6
Help with an expression to calculate a profit from one of three fi 2
DSum 1

Top