Maybe function Mark will help you. Example with pseudocode.
Rec.RESET;
Rec.CLEARMARKS;
Rec.SETRANGE(*here is your filter from subform link*);
IF Rec.FINDSET THEN REPEAT
Rec.CALCFIELDS("Total amount");
IF Rec.ReceiptAmount - "Total amnount" > 0 THEN
MARK(Rec,TRUE);
Until Rec.Next = 0;
MARKEDONLY(Rec,TRUE);
Answers
Where to write this Code
Thanks