Board index » delphi » Can i create Calculated fields at runtime???

Can i create Calculated fields at runtime???

How can i create a calculated field at runtime? if it's possible,  i
couldn't doit without closing the dataset, right?

--
Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

 

Re:Can i create Calculated fields at runtime???


Quote
>how can i create a calculated field at runtime?

Here is an example

var
  f : TField;
  i : integer;
begin
 table1.FieldDefs.Update
  Table1.Close;
  for i := 0 to Table1.FieldDefs.Count - 1 do
   //create persistent field that do not exist
   if table1.FindField(table1.FieldDefs[i].Name) = nil then
      table1.FieldDefs.Items[i].CreateField(Table1);
//create a calculated field
  f := TStringField.Create(Table1);
  f.Name := 'Table1CalcField';
  f.FieldName := 'CalcField';
  f.DisplayLabel := 'CalcField';
  f.Calculated := True;
  f.DataSet := Table1;
  Table1.Open;
end;

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Can i create Calculated fields at runtime???


it's impossible to doit without closing the table, right?

--
Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

Re:Can i create Calculated fields at runtime???


it's working by now....
i'm destroying it doing :

 Table.Close;
 F.Free;      //"F"  is the calculated field.
 Table.Open;

Is this OK?

THANKS

ps: Sorry bout the email, i pressed replay instead of replaygroup.
--
Merry Christmas and Happy New Year!!!
Emiliano Sosa
Software dep.
Sierra S.R.L. www.gosierra.com
Buenos Aires Argentina

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:l45i2ucbmrc5sumdrlgffmt0mn83lqg9or@4ax.com...

Quote
> >it's impossible to doit without closing the table, right?
> correct
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Can i create Calculated fields at runtime???


Quote
>it's working by now....
>i'm destroying it doing :

I don't see any reason you need to destroy the calculated field you create.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Can i create Calculated fields at runtime???


it's working by now... I asked you just to be sure.

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:qtsk2ukd6p8f3ko67u16e1asnr5ig4hb3l@4ax.com...

Quote

> >it's working by now....
> >i'm destroying it doing :

> I don't see any reason you need to destroy the calculated field you
create.
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads