Total when deleting subform row

Total when deleting subform row

I have a subform which contain a field 'SubAmount' ,which gets summed to 'Amount' in the main form.  

Is there a way for the parent form 'Amount' total to update after a sub form row has been removed, but before the main form has been submitted?

I've tried this "On Delete Row", but it doesn't seem to be working.

  1. delete from Washpack_SubAmount[ ID == row.ID ];
  2. grandTotal = 0.0;
  3. for each item in SubAmount
  4. {
  5.     if (item.SubAmount  !=  null)
  6.     {
  7.         grandTotal = (grandTotal  +  item.SubAmount);
  8.     }
  9. }
  10. input.Amount = grandTotal;