Recalculate fields in subform from Main form

E

Edwin M

I have a main form which shows job records (income and expenditure items) and
calculates Net Profit.
This form contains a sub form with a number of workers payment records
linked to the job and allows the entry of percentage of net profit then
calculates share amount. i.e [share amount] = [percentage of profit] * [Net
Profit].
All this works well until the main form items are edited (for errors etc)

How can I automatically update (recalculate) all the payment records from
the main form (when a field is edited)?
 
M

Marshall Barton

Edwin M said:
I have a main form which shows job records (income and expenditure items) and
calculates Net Profit.
This form contains a sub form with a number of workers payment records
linked to the job and allows the entry of percentage of net profit then
calculates share amount. i.e [share amount] = [percentage of profit] * [Net
Profit].
All this works well until the main form items are edited (for errors etc)

How can I automatically update (recalculate) all the payment records from
the main form (when a field is edited)?

It sounds like all you need is to requery the subform:

Me.[subform control name].Form.Requery

Try putting that line of code in the main form's AfterUpdate
event procedure.
 
D

Daryl S

Edwin -

Where is the code that does the calculation intially, and how that code
triggered? Can you re-run that code? It would be better to have one piece
of code to do these calculations than the same code in two places.

If the code is in a query against the tables, save the form record, re-run
the calculation code, and then refresh your data on the form. If the initial
calculations are done on the form or subform, call that code again.

Give us a little more information, and we may be able to be more specific...
 

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