Timing of update of subform totals

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
 
A

Allen Browne

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.
 
J

JRM

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top