Subtract the value of the field in the subform from field in the mainform, When user deletes the record in Subform

Subtract the value of the field in the subform from field in the mainform, When user deletes the record in Subform

Hi,
i have a field called subtotal in the subform and a field called GrandTotal in mainform, when user deletes the record from the subform i want to subtract that value from the GrandTotal .
Please help me with the deluge script .
Thanks in advance .