Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Query Problem

Status
Not open for further replies.

meinhunna

Programmer
Jul 31, 2004
118
AU
I have following query written in my Access DB.

SELECT PriceVale
FROM tblTrans
WHERE ItemID = 1001

My problem is I want this query to return 0 if record is not found in the table. Apparently it returns empty field.

I tried using Nz functions as follows, but still it doesn't return 0

SELECT Nz(PriceVale,0)
FROM tblTrans
WHERE ItemID = 1001

Please help. Thanks
 
SELECT PriceVale
FROM tblTrans
WHERE ItemID = 1001
UNION
SELECT 0
FROM tblTrans
WHERE NOT EXISTS (SELECT * FROM tblTrans WHERE ItemID=1001)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top