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

Subreports problems

edited July 2004 in General
Hi,

I'm trying to use differents subreports on the main report as a mean to get
the header,detail bands on the main report a different look. DataPipeline is
only attached to the main report. On the header band of the main report i
have 2 subreports type Child. Each subreport has his own customised header
band. Same thing on the detail band of the main report, 2 subreports type
Child. Each subreport has his own customised detail band. No DataPipeline
attached to the detail subreports. In the 'OnStartPage' event handler of the
main report the Visible property of each appropriate subreport (header and
detail) are set to True/false on odd/even pages. What i get is the first
page is fine, the next page header band is fine (right 1)but no data on the
detailband, 3th page is fine again, 4th page header band fine but again no
data...
I tried to to toggle the visibility in the BeforeGenerate of the mainreport
header and detail band but it didn't chnage anything. What am i doing wrong?

Greetings,
Filip Moons

Comments

  • edited July 2004
    Hi Filip,

    First keep in mind that the Header and Footer bands are not available in a
    Child Subreport. Instead you will need to use the Title/Summary or
    GroupHeader/GroupFooter bands.

    As a test, try placing a break point inside your BeforeGenerate event and
    see how many times your code is being executed. I would suggest trying the
    Report.PageStart event instead of the BeforeGenerate of a subreport or band.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Hi,

    I traced some further in 'TppBandEngine.ProcessQueue' 4 the ongenerate of
    the detailband of the mainreport

    ...
    lComponent := TppComponent(aQueue[liComponent]);
    ....


    procedure TForm1.ppReport1StartPage(Sender: TObject);
    begin
    if Odd(ppReport1.PageCount) then
    begin
    ppHeaderReport1.Visible := False;
    ppHeaderReport1.SendToBack;
    ppDetailReport1.Visible := False;
    ppDetailReport1.SendToBack;
    ppHeaderReport2.Visible := True;
    ppHeaderReport2.BringToFront;
    ppDetailReport2.Visible := True;
    ppDetailReport2.BringToFront;
    end
    else
    begin
    ppHeaderReport2.Visible := False;
    ppHeaderReport2.SendToBack;
    ppDetailReport2.Visible := False;
    ppDetailReport2.SendToBack;
    ppHeaderReport1.Visible := True;
    ppHeaderReport1.BringToFront;
    ppDetailReport1.Visible := True;
    ppDetailReport1.BringToFront;
    end;
    end;


    This is what i got
    page 1
    lComponent Detailreport2 Visible False <- subreport 2
    lComponent Detailreport1 Visible True <- subreport 1
    lComponent ppFDARCODE1 Visible True <- TppDBText 1 component on subreport 1
    lComponent ppFDAROMS1 Visible True <- TppDBText 2 component on subreport 1
    lComponent ppCODE1 Visible True <- TppLabel 1 component on subreport 1
    done generation detailband

    page 2
    lComponent Detailreport1 Visible False <- subreport 1
    done generation detailband

    No traversal of subreport 2 ???

    If i reverse the order odd/even in ppReport1StartPage

    page 1
    lComponent Detailreport2 Visible True <- subreport 2
    lComponent ppFDARCODE2 Visible True <- TppDBText 1 component on subreport 2
    lComponent ppFDAROMS2 Visible True <- TppDBText 2 component on subreport 2
    lComponent ppCODE2 Visible True <- TppLabel 1 component on subreport 2
    lComponent Detailreport1 Visible False <- subreport 1
    done generation detailband

    page 2
    lComponent Detailreport2 Visible False <- subreport 2
    lComponent Detailreport1 Visible True <- subreport 1
    done generation detailband

    I really don't understand what's goin on, mayb this can help u?

    Greetings,
    Filip

  • edited July 2004
    Nico please could u take a look, i'm sure there's nothing wrong with my
    report. If RB isn't designed to do what i want here please let me know, on
    the other hand if it is well then its making a mess...

  • edited July 2004
    Hi Filip,

    Sorry, I am unsure what you would like your report to look like. You say
    you have no data in the detail band but if your subreports inside the detail
    band are not connected to a datapipeline, there is no way for data to be
    retrieved. Also, if you are trying to determine if you are on an odd page
    or not, you should probably use the PageNo property. Page count (without
    the use of groups) will return the total number of pages in a report. In my
    testing, I was able to toggle the visibility of a subreport in the header of
    my main report successfully. Below is the code I used. Both subreports
    were in the main page header.

    procedure TForm1.ppReport1StartPage(Sender: TObject);
    begin
    if Odd(ppReport1.PageNo) then
    begin
    ppSubreport1.Visible := True;
    ppSubreport2.Visible := False;
    end
    else
    begin
    ppSubreport1.Visible := False;
    ppSubreport2.Visible := True;
    end;

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Hi Nico,

    Fixed it using regions instead of subreports. What i was trying to do was
    using subreports as a collection component with its own header and detail
    bands and print the appropriate 1 at runtime by toggle of their visible
    props on every page.

    Thx,
    Filip Moons

This discussion has been closed.