Reference TQuery fields in Report Event Code syntax

edited 11:07PM in FastReport 4.0
Hi,

I have a report connected to a tquery 'MyQuery' via a tfrxDBDataset, and it works of course very well :-)

Now I need to create a Groupdata band OnBeforePrint event in FR's IDE Event view (pascal mode).

I need to know how the following Delphi code would look like in this FR IDE Event code view. I did not find how to reference the TQuery and its fields.

****************************************
if MyQuery.FieldByName('FieldA').AsString > '' then
FRLabel1.Memo.Text := 'Filled with something'
else
FRLabel1.Memo.Text := 'Empty';
****************************************

Thanks a lot for helping me out with this
regards
Tor

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 11:07PM
    Tor
    sample
    Can i access to dataset fields with an index ?

    <frxDataset."MyField"> to frxDataset.Fields

    var
    i: Integer;
    ds: TfrxDataSet;
    list: TStringList;

    ds := Report.GetDataset('frxDBDataSet1');
    list := TStringList.Create;
    ds.GetFieldList(list);

    for i := 0 to list.Count - 1 do
    somevar := ds.Value[list]; // get field value by its name

    the best place to do this is in the empty begin end block of code in report script it is the first processed

Leave a Comment