Timing of update of subform totals

  • Thread starter Thread starter JRM
  • Start date Start date
J

JRM

I have a calculated control in the footer of a subform to provide a total of
items in the subform which are then transferred to the main form. Changes to
a record in the subform do not seem to be reflected in this control until
some point after the subform After Update event has occurred. (Using
debug.print on form After Update only provides the previous total).

What event can be used to determine when subform total has been changed?

Any comments will be greatly appreciated.

John Morgan
 
You could try forcing the calculated controls to recalculate before using
the total:
Private Sub Form_AfterUpdate()
Me.Recalc
Debug.Print Me.[Text99]
End Sub

Alternatively, use a DSum() expression to get the total directly from the
subform's table.
 
Many thanks Allen. Your suggestion worked. I had tried me.refresh and
me.requery before but all that did was to prevent the debug print line from
running.

Regards

John Morgan

Allen Browne said:
You could try forcing the calculated controls to recalculate before using
the total:
Private Sub Form_AfterUpdate()
Me.Recalc
Debug.Print Me.[Text99]
End Sub

Alternatively, use a DSum() expression to get the total directly from the
subform's table.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

JRM said:
I have a calculated control in the footer of a subform to provide a total
of
items in the subform which are then transferred to the main form. Changes
to
a record in the subform do not seem to be reflected in this control until
some point after the subform After Update event has occurred. (Using
debug.print on form After Update only provides the previous total).

What event can be used to determine when subform total has been changed?

Any comments will be greatly appreciated.

John Morgan
 
Back
Top