Thanks I will give it a try with the TITAN versions..

Chris

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Struan Judd
Sent: Tuesday, 1 December 1998 11:40
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Help with SQL Query using Calculated Fields


Chris,

You can add calculated TField descendents to the Field list at run-time.

Your just need to call <Query>.Fields.Update and <Query>.CreateFields.

Just watch out, CreateFields is a TDataSet method and is not available
from TQuery so you need a Casting Cheat type.

--
type
        TCheatDataSet = class(TDataSet);
...
procedure CreateCalculatedStringField(PFieldName: String; PQuery:
TwwQuery; PSize: Integer);
var
  LCalculatedStringField: TStringField;
begin
  //Create also some calculated fields
  LCalculatedStringField := TStringField.Create(pQuery);
  LCalculatedStringField.FieldName := PFieldName;
  LCalculatedStringField.FieldKind := fkCalculated;
  LCalculatedStringField.Calculated := True;
  LCalculatedStringField.Size := PSize;
  LcalculatedStringField.DataSet := pquery;
end;
...
        <Query>.FieldDefs.Update;
        TCheatDataSet(<Query>).CreateFields;

// And now use CreateCalculatedStringField to add calculated string
fields.

TTFN.
----
Struan Judd     <*>             EMail:          [EMAIL PROTECTED]
CJN Technologies Ltd            Phone:          +64 (9) 415 4796
All opinions mine only  Mobile: +64 (21) 685 335
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to