Hi guys, I am making a database that tracks inventory for products and I am at a wall. I want to make sure my approach is sound, and find out how I can improve the functionality of what I am trying to do.
I have three tables: 1) tblProductList (simply lists all of my products) 2) tblProductInventory (tracks the quantty of the products that are coming in) 3)tblProductBurnRate (track the qunatity of products that are being used.
For simplicity sake, let's say tblProductList has just an autonumber field and the product name. tblProductInventory has productid (refering back to the product list autonumber, with a renforced 1-many relationship) and the quantity of that shipment. tblProductBurnRate has productid ( again refering back to the product list autonumber, with a renforced 1-many relationship) and the quantity of that was used.
I can query for everything I have coming in with tblProductInventory and I can query for everything I've used with tblProductBurnRate. Both are very simple and straightforward. My porblem comes when I try and see what I have left after products have been used. You would think that it would be a simple subtraction between each of the two numbers, but access isn't liking my approach. It seems like it is having trouble knowing that product1 from tblProductInventory goes with product1 from tblProductBurnRate. Below is my query code for each of the successful indivudal queries and for one of my many unsuccessful ones.
Appreciate any help you guys can give.
SELECT tblProductList.ProductName, Sum(tblProductInventory.Quantity) AS SumOfQuantity
FROM tblProductList INNER JOIN tblProductInventory ON tblProductList.ProductID = tblProductInventory.ProductID
GROUP BY tblProductList.ProductName;
SELECT tblProductList.ProductName, Sum(tblProductBurnRate.QuantityUsed) AS SumOfQuantityUsed
FROM tblProductList INNER JOIN tblProductBurnRate ON tblProductList.ProductID = tblProductBurnRate.ProductID
GROUP BY tblProductList.ProductName;
SELECT tblProductList.ProductName, Sum([tblProductInventory]![Quantity])-Sum([tblProductBurnRate]![QuantityUsed]) AS Expr1
FROM (tblProductList INNER JOIN tblProductInventory ON tblProductList.ProductID = tblProductInventory.ProductID) INNER JOIN tblProductBurnRate ON tblProductList.ProductID = tblProductBurnRate.ProductID
GROUP BY tblProductList.ProductName, Sum([tblProductInventory]![Quantity])-Sum([tblProductBurnRate]![QuantityUsed]);