Refresh Main form From Sub Form

B

Brian

I have a form which contains information on a single record, on that form I
have a sub form which contains a datasheet view of related records from
another table, linked by Master/Child fields.

The sub form is a list of payments made by the person on the main form. On
the main form I have a text box that contains the sum of all those payments.

When I add/delete a payment on the sub-form, I want the 'totalPaid' text box
on the main form to recalculate, how can I do this without having to click a
'recalculate' button?

Thanks
Brian
 
A

Allen Browne

It is very important not to store the 'totalPaid' in the main form's table.
Instead, this should be a calculated control.

For an example of how to do that, open the Northwind sample database, the
Orders form, and look at how the Subtotal text box works (just below the
subform).

If you are determined to store the total anyway, you could use the
AfterUpdate and AfterDelConfirm events of the subform to DSum() the
appropriate total directly from the subform's table, and assign the value to
the control on the main form.
 
M

Micosoft

Allen, thanks, I'll give that a go

I'm not storing the totalPaid in a table, I just want it to re-calculate
whenever a related payment is entered into the subform.

Brian
 

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