Error while summing rows in subform

Error while summing rows in subform

Hi,

I have a subform called Bin_Weights.  I am using the following code to calculate the total net weight:

temptotalB = 0;
for each record in Bin_Weights
{
    record.Sub_Total = record.Net_Bin_Weight;
    temptotalB = (temptotalB  +  record.Sub_Total);
}
input.Total_Net_Weight = temptotalB;


The script saves but has the following errors when I run it:

Error details:
Error in executing On Add Row script of Bin ID.
Error.
Error in executing For Each Record task.
Error in executing Set Variable task. Unable to update template variable temptotalB.
Error evaluating NUMERIC expression : Unable to perform the operation + over the operand 0 and null.
Error in performing the operation + : Error.
Error in performing the operation + : Error.
Accessing the value record.{1}
I would be most grateful for any advice on this matter.

Best regards,

Jeff