Hi,
I have two tables, Table1 and DescTable selected with similar field
Now, once the record has been inserted in Table1, then a new record should be added in DescTable with the same primary key and Description of Table1.
procedure MyMethod()
var
DescTable: Record DescTable;
Table1: Record Table1;
begin
Table1.reset;
if Table1.FindSet() then begin
DescTable.Setrange(DescTable.ID, Table1.ID);
DescTable.Reset();
DescTable.Init();
DescTable.ID := Table1.ID;
DescTable.Txt := Table1.NotesTxt;
DescTable.Insert(true);
Message('Description Added');
end;
end;
It only allows me to add one record, for the second record it says the record already exists in DescTable.
Can you tell me what I'm doing wrong?
Thanks.
Solution
procedure changeCode()
var
DescTable: Record DescTable;
Table1: Record Table1;
begin
Table1.SETFILTER(Desc, '<> 0');
IF Table1.FIND(' ') THEN
repeat
begin
DescTable.Init();
DescTable.ID := Table1.ID;
DescTable.Desc := Table1.Desc;
DescTable."new Field" := createguid;
DescTable.Insert();
end;
until Table1.next <= 0;
end;