I have a Main form (an invoice) with a subform containing line items. The footer of the subform has a calculated text box containing a total. I want to set up a text box in my main form, bound to the record that is displayed in the main form, that copies the value from the subform footer. Should be simple enough...
In the AfterUpdate event for the subform, I have code that sets the text box in the main form to equal my subform total field. What seems to be happening is that the AfterUpdate event is somehow firing before the subform calculates its total in the footer. So the field in the main form always gets set to the previous value of the subform's total field. Interestingly, if I set a breakpoint in the code then everything works fine, i.e. the code breaks, I hit play, and the value in the main form sets correctly. I'm assuming that this is because I've given the subform enough time to synchronize itself before the code runs.
I've tried to do several things to force the subform to recalculate before setting the field in the main form. I've use the refresh and requery methods on the subform. I also tried setting the focus to the total field on the subform before running my code. Nothing works.
Any ideas?
thanks in advance
In the AfterUpdate event for the subform, I have code that sets the text box in the main form to equal my subform total field. What seems to be happening is that the AfterUpdate event is somehow firing before the subform calculates its total in the footer. So the field in the main form always gets set to the previous value of the subform's total field. Interestingly, if I set a breakpoint in the code then everything works fine, i.e. the code breaks, I hit play, and the value in the main form sets correctly. I'm assuming that this is because I've given the subform enough time to synchronize itself before the code runs.
I've tried to do several things to force the subform to recalculate before setting the field in the main form. I've use the refresh and requery methods on the subform. I also tried setting the focus to the total field on the subform before running my code. Nothing works.
Any ideas?
thanks in advance