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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Calculation

Status
Not open for further replies.

mtompkins

IS-IT--Management
Jan 14, 2003
166
US
I have the following query:

Code:
SELECT [Inventory Transactions].TransactionDescription, Products.ProductName, [Inventory Transactions].UnitsReceived, [UnitsReceived]-[Qty] AS QtyAvail, qryCompOut.Qty
FROM Products INNER JOIN (qryCompOut RIGHT JOIN [Inventory Transactions] ON qryCompOut.comp = [Inventory Transactions].TransactionDescription) ON Products.ProductID = [Inventory Transactions].ProductID
GROUP BY [Inventory Transactions].TransactionDescription, Products.ProductName, [Inventory Transactions].UnitsReceived, [UnitsReceived]-[Qty], qryCompOut.Qty
HAVING ((([Inventory Transactions].UnitsReceived)>0));

which produces the intended calculation except in instances where there is no data (NULL) for "Qty". Can someone please help me produce the calculation in these cases (i.e. Qty should revert to a zero in the case of null).

Thanks
 
Replace this:
[UnitsReceived]-[Qty]
By this:
[UnitsReceived]-Nz([Qty],0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks - that was it. Hate when you forget the "easy" ones.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top