No it's created at runtime:

  q := TQuery.Create(Nil);
    q.DatabaseName := 'Rezy';
q.SQL.Add('Select Surname, Tit_Init, Greeting, StNo, Street, Add2, Add3, Ph1, Ph1Type, Ph2, Ph2Type, Ph3, Ph3Type, Fax, Price, Bedrooms, email');
    q.SQL.Add('from contact where status = ''A''');
    q.Name := 'Contact';
//    q.OnCalcFields := qContactCalcField;
//    strfield := TStringField.Create(q);
//    strfield.FieldName := 'RequirementsDesc';
//    strfield.FieldKind := fkCalculated;
//    strfield.DataSet := q;
    q.Open;

The commented out bit creates the calculated field which obscures the other fields once created. I want to be able to add all the other fields to the q.Fields property, but not have to write the code to add each field individually.

Any Suggestions?

Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington

Todd Martin wrote:
Are your existing fields in the dataset create at design time?

----- Original Message ----- From: "Alister Christie" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Delphi List" <[email protected]>
Sent: Tuesday, May 31, 2005 1:29 PM
Subject: [DUG] Creating fields at runtime


I'm creating a TQuery (descriptively called q) at runtime with a with a query such as "select * from contact". However I want to add a calculated field to this using the following code
    strfield := TStringField.Create(q);
    strfield.FieldName := 'RequirementsDesc';
    strfield.FieldKind := fkCalculated;
    strfield.DataSet := q;
However, by adding a calculated field I hide all the fields in the fielddefs. Does anyone know of a way around this, either by putting the calculated field in q.fielddefs or adding all the fields to q.fields in some easy fashion


--
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi




_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to