Using Aggregate Fields With TClientDataSet
Delphi’s TClientDataSet provides support for aggregate fields. In the current implementation the IsNull function of the TAggregateField returns True unless the dataset is on the first record. This is problematic since ReportBuilder relies on the IsNUll function to determine whether field value is valid.
Therefore, a work around is required to use aggregate fields in a report. One approach would be to use a Label or Variable in the report and programmatically set the value.
Example 1:
myLabel.Caption := myDataSet.FieldByName['AggFieldName'].AsString;
myReport.Print;
Example 2:
procedure myVariableOnCalc(Sender: TObject);
begin
if (myVariable.AsStrng = '') then
myVariable.Value := myDataSet.FieldByName['AggFieldName'].AsString;
end;