Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Finding objects in subreports

edited November 2013 in General
Hallo,

I've a problem finding components in subreports.
I'am running with bandcount and objectcount trough all components of the
report, but some components placed in subreports are not found.


procedure tRBConvertFrm.showcomponents();
var b,c:Integer;
Obj:TComponent;
begin
for b:=0 to report.bandcount-1 do begin
for c:=0 to report.bands[b].ObjectCount-1 do begin
Obj:=report.bands[b].Objects[c];
writememo('Obj:'+Obj.name);
end;
end;
end;

the current report has three subreports in the following structure:

report
+-- subreport3
+-- subreport1
+-- subreport2

ppDbText components on subreport1 are found by the above given code,
ppLabel components are not found ??

What must I do to get all componets on the subreports ?

When I later want to create new componets on the subreport, how can I
access it - I'am missing something like report.subreport[].
band/objects/... ?


RAD Studio 2007, RB11.08


Jürgen

Comments

  • edited November 2013
    Write a routine that can call itself. e.g.

    procedure TrbReporting.SetNumberFormatsForWholeReport(aReport :
    TppCustomReport; aCurrency : Integer);
    var
    lBandIndex : Integer;
    lObjectIndex : Integer;
    lObject : TppComponent;
    lDataPipeline : TppDataPipeline;
    lDataField : String;
    lDataType : TppDataType;
    begin

    for lBandIndex := 0 to aReport.BandCount - 1 do
    for lObjectIndex := 0 to aReport.Bands[lBandIndex].ObjectCount -
    1 do
    begin
    lObject := aReport.Bands[lBandIndex].Objects[lObjectIndex];

    if lObject is TppSubReport then
    begin

    SetNumberFormatsForWholeReport(TppSubReport(lObject).Report, aCurrency);
    continue;
    end;

    if (lObject is TppDBText) or (lObject.InheritsFrom(TppDBText)) or
    (lObject is TppVariable) then
    // only set if nothing assigned (default)
    // if TppCustomTextAccess(lObject).DisplayFormat = '' then
    begin

    lDataPipeline := TppDBText(lObject).DataPipeline;
    lDataField := TppDBText(lObject).DataField;

    if lObject is TppVariable then
    lDataType := TppVariable(lObject).DataType else
    lDataType := lDataPipeline.GetFieldDataType(lDataField);

    case lDataType of

    dtSingle,
    dtDouble,
    dtExtended : TppCustomTextAccess(lObject).DisplayFormat
    := CurrencyManager.CurrencySet[aCurrency].DecimalFomattingstring;

    dtCurrency : TppCustomTextAccess(lObject).DisplayFormat
    := CurrencyManager.CurrencySet[aCurrency].CurrencyFomattingstring;

    end;

    end;

    end;

    end;


This discussion has been closed.