Update of calculation on form when line edited on subform

Hello,

I have a form with a subform. On the main form, I have some different calculations. When I add or change a line in the subform, I want these calculations to be updated.

How can I “refresh” the main form?

Thanks in advance!

in ONVALIDATE trigger of the subform’s table field add the code to refresh / update the header table field.

Don’t forget to the post(s) that solved your problem. This credits the experts who helped, earns you points and marks your thread as Resolved so we all know you have been helped.

But how?

If I declare the main form in the subforms table, it is another instance and not the one being viewed on the screen.

I have been looking through the standard application to find a form where this is the case, but with no luck.

My problem is exactly the same if I wanted to see a invoice total on Form 51 (Purchase Invoice). How could I update a flowfield when inserting or changing lines in the subform? Maybe the answer is obvious, but I dont see how I can update the main form with code on the OnValidate triggers on the subform or the subforms table.

When I move the curser from the subform to the main form, the flowfield is updated, but this is a bit too late.

Any ideas?

You should add a function in Purchase Line table for updating the calcfields in header table, and call this function OnValidate trigger of Quantity, Unit Price and other relevant fields.

The function should do something like:

PurchHeader.GET(“Document Type”, “Document No.”);

PurchHeader.CALCFIELDS(“Define Your Fields here”);

try to explore with MODIFY and / or COMMIT. modify command will replace old value to new value right away. commit command will update the state of database.

good luck.

Dhan: This is not a solution. The PurchHeader record is not the same instance as Rec on form 51. It has no effect.

Did you try and did you succeed in making it work?

Joe: The data is modified and commit when entered in the subform, so this is not an issue. This dosnt solve the problem.

The root of the problem is, that I need to move the cursor from the subform to the main form for the Flowfield to be updated.

It is not possible to update the main form from the subform. You’d have to put some code to update (CurrForm.UPDATE) the form in the main form’s timer event. I really dislike putting code in the timer events though, that makes debugging the form almost impossible.

Thanks DenStar, I unfortunately think you are right.

You’re welcome [Y]