Renamin of a Record

sprabhucpplsprabhucppl Member Posts: 58
Hello,

I have 2 tables

Table 1 - Header
Table 2 - Line

i have written code on onrename() as


IF "Whse. Receipt No."<>xRec."Whse. Receipt No." THEN
BEGIN
"Cart Line".SETRANGE("Whse. Receipt No.",xRec."Whse. Receipt No.");
"Cart Line".SETRANGE("Carton No.","Carton No.");
IF "Cart Line".FINDSET() THEN BEGIN
REPEAT
"Cart Line".RENAME("Whse. Receipt No.","Cart Line"."Carton No.","Cart Line"."Carton Line No.");
UNTIL "Cart Line".NEXT=0;
END;
END;


if i rename "Whse. Receipt No." in header table the same have to be updated in Line Table.

but my code is updating only first record in line Table

all the other records remain same.

kindly help me how the entire records renamed.

Thanks in advance

Comments

  • JedrzejTJedrzejT Member Posts: 267
    Sometimes I do it in thay way to make sure it work..
    Maybe someone other have better solution, but this work for sure.
    This error is about Key in loop. Using another record variable for rename will dont change sort of original loop.
    IF "Whse. Receipt No."<>xRec."Whse. Receipt No." THEN
      BEGIN
        "Cart Line".SETRANGE("Whse. Receipt No.",xRec."Whse. Receipt No.");
        "Cart Line".SETRANGE("Carton No.","Carton No.");
        IF "Cart Line".FINDSET() THEN BEGIN
          REPEAT
             "Cart Line2".GET(Cartline 1 Primary key)
             "Cart Line2".RENAME("Whse. Receipt No.","Cart Line"."Carton No.","Cart Line"."Carton Line 
             No.");
          UNTIL "Cart Line".NEXT=0;
        END;
      END;
    
Sign In or Register to comment.