Hi Ghiara. I am not sure what the problem is here. I think either you are trying to stop a record section overflowing onto the next page, or you are trying to print the totals at the foot of the first page. Rocco suggested something to help with the first problem.
If you have the second problem (you want to place the totals at the bottom of the first page), then just set the Totals section to $startmode=kFromBottomMargin. It should not be necessary to calculate the number of record sections printed or the size of them.
You do not say which version of Omnis you are using – that might make a difference to the advice given.