Board index » delphi » Dataset in edit mode when scrolling

Dataset in edit mode when scrolling

Hi,

I need to set ModificationDate field to Now() when user changes
something in dataset. The datasource has AutoEdit=true.

But onAfterEdit handler called anytime I scroll (browse) the dataset.
So that my ModificationDate=time_when_user_seen_the_record.

I tried to use DataSource's onDataChange handler (see below). The
same: dsContracts.State allways =dsEdit.

Why it doing so and how to catch th moment when user changes something
(without catching onChange events of all the controls on the
form)?????

Lots of thanks
Namor

procedure Tdta.tbl_ContractsAfterEdit(DataSet: TDataSet);
begin
  if dsContracts.State in [dsInsert, dsEdit] then begin
    tbl_Contracts.FieldValues['cntModifDate']:=DateTimeToStr(now());
  end;
end;

 

Re:Dataset in edit mode when scrolling


in DataSet.BeforePost event check DataSet.Modified and
set ModificationDate only if DatSet.Modified = true

hth,
Helmut

"Namor" <na...@yandex.ru> schrieb im Newsbeitrag
news:5158815d.0302050251.6b43464d@posting.google.com...

Quote
> Hi,

> I need to set ModificationDate field to Now() when user changes
> something in dataset. The datasource has AutoEdit=true.

> But onAfterEdit handler called anytime I scroll (browse) the dataset.
> So that my ModificationDate=time_when_user_seen_the_record.

> I tried to use DataSource's onDataChange handler (see below). The
> same: dsContracts.State allways =dsEdit.

> Why it doing so and how to catch th moment when user changes something
> (without catching onChange events of all the controls on the
> form)?????

> Lots of thanks
> Namor

> procedure Tdta.tbl_ContractsAfterEdit(DataSet: TDataSet);
> begin
>   if dsContracts.State in [dsInsert, dsEdit] then begin
>     tbl_Contracts.FieldValues['cntModifDate']:=DateTimeToStr(now());
>   end;
> end;

Re:Dataset in edit mode when scrolling


On Wed, 5 Feb 2003 14:15:42 +0100, "Helmut W?ss" <h.wo...@iis-edv.at>
wrote:

Quote
>in DataSet.BeforePost event check DataSet.Modified and
>set ModificationDate only if DatSet.Modified = true

>hth,
>Helmut

Also, you can turn autoedit off in the datasource, and then use
dataset.edit to allow changing or adding a record at just the right
time.

Dan

Quote

>"Namor" <na...@yandex.ru> schrieb im Newsbeitrag
>news:5158815d.0302050251.6b43464d@posting.google.com...
>> Hi,

>> I need to set ModificationDate field to Now() when user changes
>> something in dataset. The datasource has AutoEdit=true.

>> But onAfterEdit handler called anytime I scroll (browse) the dataset.
>> So that my ModificationDate=time_when_user_seen_the_record.

>> I tried to use DataSource's onDataChange handler (see below). The
>> same: dsContracts.State allways =dsEdit.

>> Why it doing so and how to catch th moment when user changes something
>> (without catching onChange events of all the controls on the
>> form)?????

>> Lots of thanks
>> Namor

>> procedure Tdta.tbl_ContractsAfterEdit(DataSet: TDataSet);
>> begin
>>   if dsContracts.State in [dsInsert, dsEdit] then begin
>>     tbl_Contracts.FieldValues['cntModifDate']:=DateTimeToStr(now());
>>   end;
>> end;

Other Threads