DSum or another resolution for subform timing issue

new_2_prog

Registered User.
Local time
Today, 12:00
Joined
Aug 4, 2008
Messages
58
I have a main form with calculations and a subform with that has continuous lines and in the footer of the subform is a sum text box.
On the main form I have a text box that references the total text box in the footer of the subform.
So when the form loads and closes it runs through a procedure to calculate all the text boxes on the main form.
What I have noticed with my subform when I have say 10 lines and the subform is shrunk and can only show say 3
at a time there seems to be a timing issue of the subfrm total box updating versus if I made the subfrm big enough to show all 10 at
once - why is this?
How can I incorporate the sum of the fields qty & amnt in my subfrm directly into the procedure that calculates the code?
I tried DSum:
b = DSum("[line_Total]", //field name for the box on the subfrm that calculates qty * amnt for each line
"[Quote subtbl_Special_Detail_Lines]", //table that holds all the subfrm data
"[QuoteID]=" & Me![QuoteID]) //link between the main form and subfrm
When I run this code I get error 2001: You canceled the previous action.
I am at a loss and this is a big issue for me to get resolved here at work.
thanks!!
 
I would independently calculate the result you are currently trying to retrieve from the subform. You can do this by hard coding the ControlSource of the control on the main form with a DSum()--or whatever--that encapsulates the same logic that gives you the result on the subform. For readability, you may prefer to calculate this in the Current event of the main form and assign that result to a control.
Generally: To the greatest degree possible get each object to handle its own data. Dependencies between data structures are difficult to maintain, error prone, and reduce the overall flexibility of your system.
 

Users who are viewing this thread

Back
Top Bottom