Problem with REPEAT loop

Hi everyone,
I am having an issue with the following code:

Prefixe:='FCM';
SalesInvoiceHeader.RESET;
SalesInvoiceHeader.SETRANGE("Posting Date",DateFilter,WORKDATE);

IF SalesInvoiceHeader.FINDSET THEN BEGIN
REPEAT
SalesInvoiceHeader.RENAME(Prefixe+ COPYSTR(SalesInvoiceHeader."No.",3,STRLEN(SalesInvoiceHeader."No.")));
UNTIL (SalesInvoiceHeader.NEXT = 0);
END;

The problem is that the code doesn’t loop, it modifies only one record.
What’s missing in this code?
Thanks in advance :)

Try

IF SalesInvoiceHeader.FINDFIRST ``THEN BEGIN

without using

IF SalesInvoiceHeader.FINDSET THEN BEGIN

I think this will work

Can you explain how it works?

try this code

SalesInvoiceHeader.RESET;
SalesInvoiceHeader.SETRANGE(“No.”,,); //New line
SalesInvoiceHeader.SETRANGE(“Posting Date”,DateFilter,WORKDATE);
IF SalesInvoiceHeader.FINDSET THEN BEGIN
REPEAT
SalesInvoiceHeader1 := SalesInvoiceHeader;
SalesInvoiceHeader1.RENAME(‘FCM’ + SalesInvoiceHeader1.“No.”);
UNTIL SalesInvoiceHeader.NEXT = 0;

In your code how many record do you find, did you check ? May be there is only one invoice for that workdate.

You will understand the reason if you read this

http://mibuso.com/forum/viewtopic.php?f=23&t=60016