Page 1 of 1

tdatasource

Posted: 25.10.2023, 15:50
by medhome
Hi all,

I have a problem with the event manager of datasource.
I write :
procedure tfrmUserRec (Sender: TObject; Field: TField);
begin
if field =nil then statbar.text:=inttostr( recno)
else
begin
sum:=sum+field.curvalue; //calculated three times
showmessage(field.fieldname); //showed three times;
end;
end;

the record contains fields (NTIERS, DATE, NPIECE, AMOUNT )
FIRST TIME AMOUNT IS SHOWED THAT' S OK BECAUSE IT IS THE FIELD WE CHANGED
SECOND TIME NTIERS ?????????
THIRD TIME NTIERS ?????????

ANY IDEA ? ( THIS CONCERNS FREE PASCAL OR LAZARURUS );

Re: tdatasource

Posted: 26.10.2023, 13:27
by marsupilami
medhome wrote: 25.10.2023, 15:50 ANY IDEA ? ( THIS CONCERNS FREE PASCAL OR LAZARURUS );
I suggest to check that the field name is correct. Something like if Field.FieldName = 'NTIERS'.

As to why this gets called for all fields: This might be a problem in FPC.

Re: tdatasource

Posted: 27.10.2023, 16:17
by medhome
The field NTIERS is a foreign key and never be changed manualy.

Re: tdatasource

Posted: 01.11.2023, 11:10
by marsupilami
I am sorry,

in that case it should be

Code: Select all

procedure tfrmUserRec (Sender: TObject; Field: TField);
begin
  if field =nil then statbar.text:=inttostr( recno)
  else if Field.FieldName = 'AMOUNT' then
  begin
    sum:=sum+field.curvalue; //calculated three times
    showmessage(field.fieldname); //showed three times;
  end;
end;