I would like to have the sum result stored in the [tblOrders] table's "TotalLaborTime"
I'm surprised that no one has commented on how storing calculated values in a table is generally considered to be very bad practice. In spite of that and my inability to concentrate hard enough on all the comments, if one needs to have a main form control calculate the sum of a subform recordset field, two ways come to mind. 1) DSum the table that is providing the subform records, using the same criteria for the DSum that the subform is using. 2)maybe the original issue is incorrect syntax to refer to the subform? To get the subform recordset count, you'd use
Code:
Forms("MainFormName").Controls("subformControlName").Form.Recordset.Recordcount
, so I suspect there's a way to DSum this recordset, though I've never tried.
Maybe
Code:
DSum("Forms("MainFormName").Controls("subformControlName").Form.Fields(0)","Forms("MainFormName").Controls("subformControlName").Form.Recordset")
A WHERE clause would not be needed methinks.
I would say the most important thing if trying to get the sum from a subform would be the syntax required to drill down to that subform, BUT I rank the notion that one should NOT store values in a table as more important.
Last edited by Micron; 09-30-2016 at 07:39 PM.
Reason: use code tags to eliminate forum auto spacing
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.