I have a simple formula i added on delete row in my subform. but its not updating the main form until i delete the second row

I have a simple formula i added on delete row in my subform. but its not updating the main form until i delete the second row

input.Tax = 0.0;
input.Amount = 0.00;

x = 0.0;
for each row in Activity
{
    if (!row.Bid_Work)
    {
        x = (x  +  row.Amount);
    }
}
y = 0.0;
for each row in Activity
{
    if (!row.Bid_Work)
    {
        y = (y  +  row.Tax);
    }
}
input.Tax = y;
input.Material = x;
row.Total = (row.Tax  +  row.Amount);