sum all amount in a range

I created a report to get all sales amounts with and without VAT value:

Customer - OnAfterGetRecord()

CLEAR(VatEntry);

VatEntry.SETCURRENTKEY(Type,“Posting Date”,“Document Type”,“Document No.”,“Bill-to/Pay-to No.”);
VatEntry.SETRANGE(“Bill-to/Pay-to No.”,Customer.“No.”);

IF VatEntry.FIND(’-’) THEN BEGIN

IF VatEntry.Amount <> 0 THEN;

TotAmount := VatEntry.Amount + TotAmount;

END;

With this I have the range I need, but know, I don’t know how do SUM all amont in this range.

With FIND(’-’) and FIND(’+’) I only get the first and the last amount.

But I need all amounts on this range???

Thanks

Hi Luana,

try to change your code like this:

VATEntry.SETRANGE(“bill-to/Pay-to No.”,Customer.“no.”);

IF VatEntry.FIND(’-’) THEN repeat

TotAmount := VatEntry.Amount + TotAmount;

until VatEntry.next = 0;

Regards Jan

they try FINDSET .

Thanks Jan

your solution help a lot.

Regards