Hi,
As an Access novice I am trying to do a simple update of a table but keep getting an annoying error:
I have 2 tables - Products and OrderDetails
Products
ProductID
Description
StockQuantity
OrderDetails
OrderID
ProductID
Quantity
Basically I want to update the Products.StockQuantity column to subtract the sum of all orders in the OrderDetails table.
So if Product A started with a StockQuantity of 5, and there are 3 Order_Details record, each with a quantity of 2, the query should update the Products.StockQuantity record to -1.
I have tried a few permutations such as:
UPDATE PRODUCTS
set PRODUCTS.StockQuantity = PRODUCTS.StockQuantity - (
SELECT SUM(OrderDetails.Quantity)
FROM ORDERDETAILS
WHERE ORDERDETAILS.ProductID = PRODUCTS.ProductID);
but I seem to keep getting the following error:
"Operation must use an updateable query"
Help - I'm tearing my hair out here!!
Thanks,
Keith
As an Access novice I am trying to do a simple update of a table but keep getting an annoying error:
I have 2 tables - Products and OrderDetails
Products
ProductID
Description
StockQuantity
OrderDetails
OrderID
ProductID
Quantity
Basically I want to update the Products.StockQuantity column to subtract the sum of all orders in the OrderDetails table.
So if Product A started with a StockQuantity of 5, and there are 3 Order_Details record, each with a quantity of 2, the query should update the Products.StockQuantity record to -1.
I have tried a few permutations such as:
UPDATE PRODUCTS
set PRODUCTS.StockQuantity = PRODUCTS.StockQuantity - (
SELECT SUM(OrderDetails.Quantity)
FROM ORDERDETAILS
WHERE ORDERDETAILS.ProductID = PRODUCTS.ProductID);
but I seem to keep getting the following error:
"Operation must use an updateable query"
Help - I'm tearing my hair out here!!
Thanks,
Keith