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!

calculating a field in a query 1

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
I'm trying to run this query in mdb. I'm new at this, but it seems like this query should calculate a balance for BalShares. But as it is, it will only produce a balance if there is data in qrySalesSales for the lotID. All of the others return blanks in the calculated fields. Interestingly, the calculation is correct for those fields it calculates. I tried changing the table joins but still no result for the calculated fields unless there is data in qrySalesSales.
Any help would be greatly appreciated.
Thanks in advance.
SELECT tblInventory.LotID, tblInventory.SecID, tblInventory.MgrID, tblInventory.Tckr, tblInventory.Description, tblInventory.Pdate, (([tblInventory.NumShares])-([qrySalesSales.NumSold])) AS BalShares, tblInventory.Price1, ([balShares]*[Price1]) AS Cost1, tblInventory.Price2, ([BalShares]*[Price2]) AS Cost2
FROM tblInventory LEFT JOIN qrySalesSales ON tblInventory.LotID = qrySalesSales.LotID;
 
SELECT tblInventory.LotID, tblInventory.SecID, tblInventory.MgrID, tblInventory.Tckr, tblInventory.Description, tblInventory.Pdate, tblInventory.NumShares-Nz(qrySalesSales.NumSold,0) AS BalShares, tblInventory.Price1, ([balShares]*[Price1]) AS Cost1, tblInventory.Price2, ([BalShares]*[Price2]) AS Cost2
FROM tblInventory LEFT JOIN qrySalesSales ON tblInventory.LotID = qrySalesSales.LotID;


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

Part and Inventory Search

Sponsor

Back
Top