I would like to modify the value of a field which belongs to the primary key of a record. When I try to use MODIFY, error message appears saying that the record NewValue does not exist. How can I do it?
I'm trying to modify many records, but RENAME only works for the first record! ](*,)
WITH Record1 DO BEGIN
RESET;
SETRANGE(Field1,'Exemple');
SETRANGE(Field2,0);
if FIND('-') then
REPEAT
RENAME(Field1,NewField2,Field3);
UNTIL NEXT = 0;
END;
I'm trying to modify many records, but RENAME only works for the first record! ](*,)
WITH Record1 DO BEGIN
RESET;
SETRANGE(Field1,'Exemple');
SETRANGE(Field2,0);
if FIND('-') then
REPEAT
RENAME(Field1,NewField2,Field3);
UNTIL NEXT = 0;
END;
Try this instead:
Rec1.reset;
Rec1.setrange(field1,'exemple') ;
Rec1.setrange(field2,0) ;
if Rec1.find('-') then
repeat
Rec2 := Rec1 ;
Rec2.rename( field1, newfield2, field3 ) ;
until Rec1.next = 0 ;
Strange. It should work. However, I assume that renaming is not a part of your standard business process but a one-time only correction, you could write code with filevar.CREATE, filevar.TEXTMODE(TRUE),filevar.WRITE('text'); to generate hardcoded code to a textfile and copy-paste it into Navision, generating code like:
Looks like you are trying to insert more then 1 record with the same Primary key. If you have 3 fields in the primary key then based on your code you have to change value of the Field3 before RENAME.
Answers
rec.GET(primarykeyfield1,primarykeyfield2,..)
rec.RENAME(PrimaryKeyfield1NewValue,PrimaryKeyfield2NewValue,..)
Try this instead:
CLEAR(Record);
Record.GET('B112');
Record.RENAME('A134');
Ugly, but it works as a one-time solution.
http://www.mibuso.com/forum/viewtopic.p ... ght=rename
Oleg