how to detect if a page is refreshed?

Balance Field is normal decimal field.

It is a empty field in the same table where the amount field is.

Table is a new table with Doc No., Amount, Balance & some other text fields.

I do not want to write the balance to DB, just want to show it on the page at run time.

Yes if the user changes the sorting of the page or the filter, it should again start with the first record shown.

Any help?

Remove the balance field from the table, declare a Global Decimal variable named Balance instead.
Then use the code I proposed in the last posting:

Rec2.COPY(Rec);
Balance := Amount;
WHILE Rec2.NEXT(-1) = -1 DO
Balance += Rec2.Amount;

Thanks Thomas Brodkorb that works perfect.