Hi I have a problem that I hope any of you can help me solve. When renaming a company in the normal way (File, Company, Rename) I want to change the related information in another table/company. The field in this table is a part of the Primary key and I get an error when performing the following code OnRename (in the Company table): Table.CHANGECOMPANY(‘NewComp’); Table.SETRANGE(Table.Field,xRec.Name); IF Table.FINDFIRST THEN REPEAT Table.RENAME(Table.Field1,Name); UNTIL Table.NEXT = 0; Best Regards Mads Morre
Hello Mads, I guess that you just do the old error: Modifying a field that is part of the active key. Instead you should create a second varialbe pointing to the same table, get or find your record and rename it there. Othervise your next statement looses track. //Pelle
Hi Pelle I have tried what you suggested (see below). I think it could have something to do with the Company table and the fact that I am renaming a record there. Var: KontRegn Record Kontakt/regnskaber KontRegn2 Record Kontakt/regnskaber KontRegn.CHANGECOMPANY(‘Navneregister’); KontRegn.SETRANGE(Regnskab,xRec.Name); //Field is a part of pri key IF KontRegn.FIND(’-’) THEN REPEAT KontRegn2.CHANGECOMPANY(‘Navneregister’); KontRegn2.GET(KontRegn.Kontaktnummer,KontRegn.Regnskab); KontRegn2.RENAME(KontRegn2.Kontaktnummer,Name); UNTIL KontRegn.NEXT = 0; Regards mads morre