update query with dsum()

Thevince

Registered User.
Local time
Today, 17:58
Joined
Aug 2, 2014
Messages
15
Hi guys

I have a table products with a field "id_product" and "total" (Total items in stock)

I have a query with the fields "id_product" and also the field "total in stock"

I want an update query to update the field 'total' in table 'products' with infos
from that query

For each id-product in table products, replace the field total with the field 'total in stock' from the query

So I want to update a filed in a specific table with infos form another table

Is this possible ?

Thanks
 
Possible, yes; advisable, no. You shouldn't store caclulated values, you should instead....calculate them.

Also, DSum generally isn't the right way to do this in a query. It's a domain function and isn't the most efficient way to Sum data. Instead you should use the SUM function of SQL:

SELECT id_product, SUM(qty) FROM YourTransactionTable GROUP BY id_product;

Instead of having to run this query, do the update then reference the table to find out stock levels, you simply reference the query.
 

Users who are viewing this thread

Back
Top Bottom