Board index » delphi » Question regarding TTable.AfterPost, probably very simple..?

Question regarding TTable.AfterPost, probably very simple..?

Hi all

My question is :-

If I write an event handler such as

procedure TRecForm.SlipTableAfterPost(DataSet: TDataSet);
begin
        // how can I find out if the table
        // has just posted a new record
        // or has just posted some changes
        // to an existing record?
end;

I suppose one way would be to set a flag in the OnNewRecord event and
test the flags condition in the AfterPost event.
Is there a flag of some sort in the DataSet variable that I could test?

Many thanks to you all.

--
zizzin

 

Re:Question regarding TTable.AfterPost, probably very simple..?


In article <ajuloAAIKT51E...@zworld.demon.co.uk>, zizzin
<ziz...@zworld.demon.co.uk> writes

Quote
>Hi all

>My question is :-

>If I write an event handler such as

>procedure TRecForm.SlipTableAfterPost(DataSet: TDataSet);
>begin
>        // how can I find out if the table
>        // has just posted a new record
>        // or has just posted some changes
>        // to an existing record?
>end;

>I suppose one way would be to set a flag in the OnNewRecord event and
>test the flags condition in the AfterPost event.
>Is there a flag of some sort in the DataSet variable that I could test?

That's what I do. I have tables in a datamodule, and I've created
private boolean fields of the datamodule for this purpose. You can
do this in a form too.

type
  TRecForm = class(TForm)
  :
  private
    FNewSlipRecord : boolean;
  end;

procedure TRecForm.SlipTableNewRecord(DataSet : TDataSet);
begin
  FNewSlipRecord := True;
end;

procedure TRecForm.SlipTableAfterPost(DataSet: TDataSet);
begin
  if FNewSlipRecord then begin
    //do stuff
    FNewSlipRecord := False;
  end
  else
    //do other stuff
end;

You may want to encase the above in a try..finally so that
FNewSlipRecord gets set to False even if an error occurs.
--
Jeremy Collins
Kansai Business Systems

Other Threads