A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

#Error Message



 
 
Thread Tools Display Modes
  #1  
Old March 15th, 2005, 02:13 PM
TiffyMilly
external usenet poster
 
Posts: n/a
Default #Error Message

I have been working on a database that calculates the cost/usage of the
peridocials by dviding the cost by the usage. If the value of the usage is
0, then the cost per usage is displayed as #Error. How can I have this
#Error replaced by a zero.

See below the SQL Statements I have used to calculate this value:


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 matter will be appreciated.

Sincerely,

Tiffany Miller

  #2  
Old March 15th, 2005, 02:25 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

Use IIf() to test if [use] is zero:
SELECT Listings.Title, Listings.Cost, Listings.Use,
IIf([use]=0, 0, [cost]/[use]) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;

Better still:
SELECT Listings.Title, Listings.Cost, Listings.Use,
CCur(Nz(IIf([use]=0, 0, [cost]/[use]),0)) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;
Explanation of why:
http://allenbrowne.com/ser-45.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TiffyMilly" wrote in message
...
I have been working on a database that calculates the cost/usage of the
peridocials by dviding the cost by the usage. If the value of the usage
is
0, then the cost per usage is displayed as #Error. How can I have this
#Error replaced by a zero.

See below the SQL Statements I have used to calculate this value:


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 matter will be appreciated.

Sincerely,

Tiffany Miller



  #3  
Old March 15th, 2005, 02:35 PM
TiffyMilly
external usenet poster
 
Posts: n/a
Default

Thank you, you were more than helpful. I was wondering, I'm new to
Microsoft Access and only slightly familiar with SQL, do you know of any good
online resources where I can learn more. I'm very interested in becoming a
better coders. As of now the only sites I use are w3schools.com and this
site.

Thank you for your Assistance again.

Tiffany Miller

"Allen Browne" wrote:

Use IIf() to test if [use] is zero:
SELECT Listings.Title, Listings.Cost, Listings.Use,
IIf([use]=0, 0, [cost]/[use]) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;

Better still:
SELECT Listings.Title, Listings.Cost, Listings.Use,
CCur(Nz(IIf([use]=0, 0, [cost]/[use]),0)) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;
Explanation of why:
http://allenbrowne.com/ser-45.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TiffyMilly" wrote in message
...
I have been working on a database that calculates the cost/usage of the
peridocials by dviding the cost by the usage. If the value of the usage
is
0, then the cost per usage is displayed as #Error. How can I have this
#Error replaced by a zero.

See below the SQL Statements I have used to calculate this value:


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 matter will be appreciated.

Sincerely,

Tiffany Miller




  #4  
Old March 15th, 2005, 02:52 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

The links I recommend for Access are listed he
http://allenbrowne.com/tips.html#links

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"TiffyMilly" wrote in message
...
Thank you, you were more than helpful. I was wondering, I'm new to
Microsoft Access and only slightly familiar with SQL, do you know of any
good
online resources where I can learn more. I'm very interested in becoming
a
better coders. As of now the only sites I use are w3schools.com and this
site.

Thank you for your Assistance again.

Tiffany Miller

"Allen Browne" wrote:

Use IIf() to test if [use] is zero:
SELECT Listings.Title, Listings.Cost, Listings.Use,
IIf([use]=0, 0, [cost]/[use]) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;

Better still:
SELECT Listings.Title, Listings.Cost, Listings.Use,
CCur(Nz(IIf([use]=0, 0, [cost]/[use]),0)) AS [Cost per Use],
Listings.Code, Listings.Supplier
FROM Listings
ORDER BY Listings.Title;
Explanation of why:
http://allenbrowne.com/ser-45.html


"TiffyMilly" wrote in message
...
I have been working on a database that calculates the cost/usage of the
peridocials by dviding the cost by the usage. If the value of the
usage
is
0, then the cost per usage is displayed as #Error. How can I have this
#Error replaced by a zero.

See below the SQL Statements I have used to calculate this value:


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 matter will be appreciated.

Sincerely,

Tiffany Miller



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.