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

Group header page break in Sub reports

edited June 2005 in Subreports
Hi

I have a report with two data sets. I needed to display both sets of data
after each other with out a page break bewteen them. I have created a main
report with 2 sub reports ( 1 for eah data set) in a region. Both sets of
data share the same header information except for the column heading, so I
created a group header on the second subreport so that i could display
different column headings. I have tried to set all the 'Keep Together'
flags on the sub reports and group header settings to True but it insists on
doing a page break for the second subreport.

Can anyone suggest a way of stoping the page break for the second subreport?

All sub reports are pbChild. The second Subreport is set relative to the
first.

Delphi 7, Rbuilder Enterprise 7.04

Cheers
George Tziros

Comments

  • edited June 2005
    Hi George,

    Be sure the second subreport's KeepTogether property is set to False if you
    do not want it to start a new page. Also be sure your group is not set to
    start a new page (this is defined in the group dialog).

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2005
    Cheers Nico

    That worked - had to also uncheck the 'Keep together' property on the group
    dialog.

    George


  • edited October 2011
    Hello,
    I seem to have a similar situation:

    - 1 main report contains a subreport in it's detail band.
    - The subreport has two groups: one for main heading, one for subheading.
    - Both groups are set to *not* start a new page and KeepTogether is set to
    false either.
    - In the detailband of that subreport there is another subreport with
    details and it's KeepTogether propterty is set to true.

    All this works except one case:
    if the second subreport for details doesn't fit into the remaining space on
    the page, to be more precise if it's *first* record doesn't fit into the
    remaining space, it's being printed on the next page, but the group header
    (the second group with subheading) is being printed on the previous page
    *alone*, i.e. without any details on that page.

    How can I prevent this? There is no point to print just the group header,
    with all details on the next page. KeepTogether = true of the group would
    fix that, but then the behaviour would be, that *all* details will be
    printed on the next page (including the header), if the *whole* group
    doesn't fit into the remaining space. That's not how I would like my report
    to work.

    So I need a way to hide the group header on page X, if that said page X
    doesn't have any details on it. I guess DetailBeforeGenerate or so is being
    fired in that case anyway, since a part of the detail *could* fit into the
    remaining space and since it's just visible on the next page due to
    KeepTogether of the subreport set to true.

    Any ideas?

    Regards,
    Mark


  • edited October 2011
    Mark,

    Take a look at the following example on hiding an orphaned group header.
    This is not exactly what you are trying to accomplish but it should
    get you on the right track.

    http://www.digital-metaphors.com/tips/HideOrphanGroupHeader.zip

    Best Regards,

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

    thank you for the tip - looking into it now.

    Do I see it right, that it can only be done in Delphi and not in RAP?

    Doesn't it make sense to implement this behaviour by design or introduce
    some options to control it? Personally I can't see any usage of / for an
    orphaned group header and would expect it to work in the way I'm trying to
    get it working right now.

    Mark

  • edited October 2011
    Hi Mark,

    This can be done in RAP (with pass-thru functions). This would be a
    nice feature of report groups. We will consider this for a later
    release of ReportBuilder.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2011
    Sounds good Nico, thank you! :)

    Regards,
    Mark

  • edited October 2011
    Hi Nico.

    first I thought, that it would be enough to create a pass-thru function for
    "ppToMMThousandths" because it's not available in RAP, but then I saw, that
    "mmPrintableHeight" (Report.PrinterSetup.PageDef.mmPrintableHeight) is not
    available in RAP either. So I need to create a pass-thru function for the
    complete "ppGroupHeaderBand1BeforePrint"-event from the example you sent me,
    so that in RAP only this would remain then: GroupHeaderBand.OutOfSpace :=
    MyPassThruFunction;

    Correct?

    Regards,
    Mark

  • edited October 2011
    Yes, with the current version of ReportBuilder, most of the code would
    need to be inside a passthru function.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2011
    I'm calling the pass-thru function in OnBeforePrint of the GroupHeaderBand
    in my SubReport.
    It's being executed for each group. First time seems to work. From the
    second time an AV occurs in ppToMMThousandths (apparently).

    Maybe something is wrong with my parameters... I'm trying it with the
    following signature:
    'function IsOrphanGroupHeader(CurrentReport: TppReport;
    GroupHeaderBandHeight, FooterBandHeight, DetailBandHeight: single):
    boolean;'

    Because it's within a subreport, I'm not sure what I should pass as
    paramters.
    - There is no footer in my subreport, but there is one in the mainreport.
    What to pass? 0 or the height of the mainreport.footer?
    - There are two details: in the subreport and also in the mainreport. What
    to pass?
    - Also not sure if Report of my subreport shall be passed or the one of the
    main report?

    If it's about the mainreport: how do I do that from a subreport?


  • edited October 2011
    After a few more attempts it looks a bit better now.

    I call the function with

    GroupHeaderBand10.OutOfSpace := IsOrphanGroupHeader(Report.MainReport,
    GroupHeaderBand10.Height, Report.MainReport.Footer.Height,
    Report.MainReport.Detail.Height);

    instead of

    GroupHeaderBand10.OutOfSpace := IsOrphanGroupHeader(Report,
    GroupHeaderBand10.Height, 0, Detail.Height);

    and at least no AV occurs, but the goal is still not achieved, since the
    GroupHeader remains on the one page, although next detail is being printed
    on the next page.


  • edited October 2011
    Hi Mark,

    Have you tried this with the demo with any success? In my testing the
    demo seemed to function correctly in that is removed an orphan group
    header when no details were present below it.

    If your case is different, I would need to see an example to find a
    solution.

    Also note that RB 14 was just released with a built-in feature to hide
    group header/footer orphans.

    Best Regards,

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

    the demo is working.
    My template is a bit more complex though:
    - main report with several subreports on it's detail band
    - one of the subreports contains two groups and another subreport on it's
    detail band
    - the header of one of the groups (the inner one) is being printed as
    orphaned sometimes

    Because of that structure I'm not sure what heights exactly need to be
    passed to the pass-thru function (those from subreports, from main reports,
    mixed, ...) and depending on the answer here: how to get them.

    I can send you my template, but since it contains many data aware elements
    on it, you would also need my DB, some more project units etc. To create a
    sample project using BDE is too time intensive, I fear :(

    Would an archive file help?

    Regarding RB14 release: I've noticed it, thanks! Also for implementing the
    orphan-group handling.
    The "problem" here is, that it's a major release which has to be purchased
    again ;)
    We will see...

    Regards,
    Mark


This discussion has been closed.