Board index » delphi » TTable Copy Record

TTable Copy Record

Hello,

is there a easy way too copy one record with all fields value too a new one
?

Per

 

Re:TTable Copy Record


Maybe something like the following if the field names are the same in
both tables:

var i: Integer;
begin
  with FromTable do
    for i := 0 to FieldCount - 1 do
      ToTable.FieldByName(Fields[i].FieldName).Assign(Fields[i]);
end;

If you want something faster, look at the BDE API manual.

Quote
"PER WESTR?M" wrote:

> Hello,

> is there a easy way too copy one record with all fields value too a new one
> ?

> Per

Re:TTable Copy Record


Assuming the two tables have the same structures and no calculated or lookup
fields:

for I := 0 to SourceTbl.FieldCount - 1 do
  DestTbl.Fields[I].Assign(SourceTbl.Fields[I]);

--
Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Other Threads