Calculations using scripts in a form or a subform

Calculations using scripts in a form or a subform

I have a form with a numeric field calculated using a custom function ( not a formula field ) . It works well .

When I use this form as subform calculation is not executed

( The script runs after you upgrade one of the two fields required for the calculation )

Any help?