page subtotal problem

Hi friends, I have a very annoying problem on my report SalesInvoice. On SalesInvoice, I want to add new field to display the toal of amount OF EACH PAGE. My current solution is to declare a global varialble and increase it after the element.sent(CustInvoiceTrans); sum += CustInvoiceTrans.LineAmount; Then I create a page footer to display this value. And it seems to work very good. BUT THE PROBLEM IS: when ItemName is multilines, then the sum is incorrect. Id ther is an Item hhas somline in page 1 and somlines in page 2. Sum value dose not include this line Aount. Can anybody help me?