I need to rename all the lines in the table, however, I only get the first line renamed. How do i get them all renamed?
Here is my code.
InvLine.SETRANGE(“Document No.”, OldDocNo);
IF InvLine.FIND(’-’) THEN BEGIN
WITH InvLine DO
REPEAT
InvLine.RENAME(NewDocNo,InvLine.“Line No.”);
UNTIL InvLine.NEXT = 0;
END;
Thanks,
Colin
Hi Colin,
This is actually a classics!
When you renames InvLine then you’re also moving the pointer. So you’ll need to do a bit more in your repeat/until loop:
REPEAT
InvLine2 := InvLine;
InvLine.RENAME(NewDocNo,InvLine."Line No.");
InvLine := InvLine2;
UNTIL InvLine.NEXT = 0;
…or more simple:
REPEAT
InvLine2 := InvLine;
InvLine2.RENAME(NewDocNo,InvLine2."Line No.");
UNTIL InvLine.NEXT = 0;
[;)]
Oh yes, that’s another (and more simple) way to do it.
Thanks guys, I checked some back threads but the answer was not as clear as this.
Now I have to go and find all those pesky records that only had the single line changed.
Cheers,
Colin[:@]
You’re welcome Colins. I just remembered that I once many years ago saw this problem in a NAV development test.