Null value handling in Subform

Null value handling in Subform

First, please accept my apologies for my poor English.

The followings codes work perfectly for my main/sub form setup. Until when some records are carrying no subform records. 

I google for the solution for almost 2 days now. But I still have no glue.


for each row in input.Shipping_Quantity
{
    x = (x  +  row.Shipping_Qty_Packs);
    input.Total_Shipped_Qty = x;
}

Thanks!