Trying to total a sum for inventory

Trying to total a sum for inventory

Hello,
Currently,  I am trying to track the running total of my inventory on a basic level.  I have a "Quantity Onhand" field and a "Quantity Received" field.  On submit, I would like the amount (Quantity Received) of the Product to be added to the Quantity Onhand.  I am very new to scripting so any suggestions would be greatly appreciated.


Here is what I have on the Quantity Onhand field on Update:

temp = 0;
for each rind in Order_form  [Quantity_Received == input.Quantity_Received]
{
    temp = (temp  +  rind.Quantity_Received);
}
input.Quantity_Onhand = temp;



Thanks,

Mark