benkingery
Registered User.
- Local time
- Today, 15:44
- Joined
- Jul 15, 2008
- Messages
- 153
I have a table that stores individual costs associated with products in my database, and then also stores the sum of those costs in a "Finished Cost" column. I do need to store the "Finished Cost" data because we use it all over the place. I'm wondering what is the best way to automatically sum the rows so this field is automatically populated. I have an Update Query that works and goes something like this:
UPDATE Parent_Table SET Parent_Table.Fin_Cost = [Parent_Table].[Cost1]+[Parent_Table].[Cost2]+[Parent_Table].[Cost3]+[Parent_Table].[Cost4];
Like I said, this works, but it performs this query for all records within the database, so it takes a little while to perform.
I have added a control to the form that interacts with this table that when clicked activates a RunSQL macro that contains the above SQL statement. As you can imagine, it takes a while for the whole thing to run because it has to update the whole table.
Does anyone have any idea on how to sum up these 4 costs into the "Finished Cost" column and then store that sum into the table?
UPDATE Parent_Table SET Parent_Table.Fin_Cost = [Parent_Table].[Cost1]+[Parent_Table].[Cost2]+[Parent_Table].[Cost3]+[Parent_Table].[Cost4];
Like I said, this works, but it performs this query for all records within the database, so it takes a little while to perform.
I have added a control to the form that interacts with this table that when clicked activates a RunSQL macro that contains the above SQL statement. As you can imagine, it takes a while for the whole thing to run because it has to update the whole table.
Does anyone have any idea on how to sum up these 4 costs into the "Finished Cost" column and then store that sum into the table?