Add up values of one field of two forms base on the value of another field

Add up values of one field of two forms base on the value of another field

Hi 

I have two forms:

Form A: Add_product , contains fields of product name, Product description, EC code and sales
Form B: Sales_report, contains fields of EC_code and sales

I want to send the value of sales from Form B to Form A and keep adding up when there is new record, when EC code of two forms are the same.

And here is the code i wrote:

fet=Add_Product[EC_Code == input.EC_Code];

fet.Sales = fet.Sales + input.Sales;


I try to execute the code when the Sales_report is successfully submitted.

However the code doesn't work and returns the error message when i submit Form B:

Error in executing On Add- On success script.
Unable to update the values to fet.Sales. Line:(2)
Null value occurred while performing addition operation: Line:(2)

Can you help?

thanks a lot!