Mega Code Archive

 
Categories / Delphi / Examples
 

Append a copy of your current record

Append a copy of your current record. {************************************************ // procedure AppendCurrent // // Author: Steve Zimmelman // Date : 06/04/1996 // // Version: Delphi 2 and Higher // // Will append an exact copy of the current // record of the dataset that is passed into // the procedure, and will return the dataset // in edit state with the record pointer on // the newly appended record. ************************************************} Procedure AppendCurrent(Dataset:TDataset); Var aField : Variant; i : Integer; Begin // Create a variant Array aField := VarArrayCreate( [0,DataSet.Fieldcount-1], VarVariant); // read values into the array For i := 0 to (DataSet.Fieldcount-1) Do Begin aField[i] := DataSet.fields[i].Value ; End; // Add a new record DataSet.Append ; // Put array values into new the record For i := 0 to (DataSet.Fieldcount-1) Do Begin DataSet.fields[i].Value := aField[i] ; End; End;