DelphiFAQ Home Search:

Copy the current record of a dataset

 

comments4 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

I found this routine which copies the current record of the currently selected record. This is useful e.g. to keep a temporary record for display in a form.


{************************************************
// procedure AppendCurrent
//
// Written By: Steve Zimmelman
// 6/4/96
//
// Version: Delphi 2.0
//
// 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 currently 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;
  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;

Comments:

2007-05-28, 16:08:11
anonymous from Debrecen, Hungary  
rating
Small and practical, I was exactly in need for it.
2008-01-18, 11:00:11
anonymous from Argentina  
¿Field readOnly As Autoincremet? For example Identity
2009-04-15, 05:35:59
anonymous from Ukraine  
thanks, exactly what i am looking for
2009-05-24, 16:06:49
anonymous from Portugal  
Very nice

But how can i duplicate de Subfieldes os the Master Table i use Ado

Rebotea@gmail.com

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.