Subform Totaling of Invoice

Subform Totaling of Invoice

I'm not the most skilled at coding, but I think something is wrong.  I have created an order form that is similar to other templates I have seen online.  I am having an issue getting Total amount of all the item subtotals entered into a subform.  When I select the item, the subtotal of the item is populating, but the addition procedure to get the total is failing.

I had this working before.  I created a new application just to test this issue and make sure none of my other code was interfering.  I even tested this in the sample application "Order Management" and there seems to be an issue there, too.

Item - table containing items
Item_Order - used as the subform with Item.ID, price, quantity, and subtotal
Subform field is Items
Total is field on parent form with the total of all subtotals

x = Item[ID == row.Item];
row.Price=x.Price;
row.Quantity=1;
if(row.Price != null && row.Quantity != null)
{
row.Subtotal=row.Price * row.Quantity;
}
t = 0.0;
if(row.Price != null && row.Quantity != null)
{
for each  rec in Items
{
t = rec.Subtotal + t;
}
}
input.Total = t;


Every time I do this starting yesterday evening, I am able to calculate the subtotal in the subform, but I get the following error every time it calculates the total:

Null value occurred while performing Addition operation.

It always references the line of code containing "t = rec.Subtotal + t;"

I'm not sure what the issue is, but I need help.

Thanks!