I want to change this peace of code

 procedure tfrmbasePagefo.DoSum(oDbGrid: TDbwidgetgrid; iRow:integer);
VAR  n:currency; nn:integer; iCol:integer; oField:TField;

begin
with oDbGrid,oDbGrid.datalink.datasource do
for iCol:=0 to datacols.count-1 do
 with datacols[iCol]   do
 if  tag>0 then
 begin
  oField:=dataset.fields[tag-1];
  if (oField.datatype = ftinteger)  then
  begin
   tmsebufdataset(DataSet).sumfield(oField,nn);
   
fixrows[iRow].captions[iCol].caption:=format(tnumericField(oField).DisplayFormat,[nn]);
   end
   else
   begin
   tmsebufdataset(DataSet).sumfield(oField,n);
   
fixrows[iRow].captions[iCol].caption:=format(tnumericField(oField).DisplayFormat,[n]);
   end;  end; end;

with this one

//  n = result even if ofield type is integer //

procedure tfrmbasePagefo.DoSum(oDbGrid: TDbwidgetgrid; iRow:integer);
VAR  n:currency;  iCol:integer; oField:TField;

begin
with oDbGrid,oDbGrid.datalink.datasource do
for iCol:=0 to datacols.count-1 do
 with datacols[iCol]   do
 if  tag>0 then
 begin
  oField:=dataset.fields[tag-1];
   tmsebufdataset(DataSet).sumfield(oField,n);
  
fixrows[iRow].captions[iCol].caption:=format(tnumericField(oField).DisplayFormat,[n]);
   end;   end;


Med

________________________________
De : fredvs <fi...@hotmail.com>
Envoyé : mardi 18 mai 2021 17:42
À : mseide-msegui-talk@lists.sourceforge.net 
<mseide-msegui-talk@lists.sourceforge.net>
Objet : Re: [MSEide-MSEgui-talk] BufDataset

Re-hello Med.

> Now summing  ftinteger  FIELD into  currency  VAR  gives 0 ?

Sorry but I dont understand.

Why do you want to sum ftinteger field into a currency var?

Why not sum ftinteger field into a integer var and after this, convert the
integer var into a currency ?



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/


_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to