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

Page Break for Each Subreport

edited March 2003 in Subreports
I have a report that consists basically of a header/footer and 4
subreports in the detail band. I want each subreport after the first
visible one to print starting on a separate page without creating blank
pages in the report. The basic algorithm is that when a subreport other
than the first visible one prints, if it isn't already at the beginning of
a page, insert a page break before printing the subreport.

I've read through various suggestions to implement this. Setting the
SubReport.PrintBehavior to pbSection seems to force a page break even if
the subreport in question didn't print due to no records. Creating groups
for this purpose seems like a bad hack, since my report doesn't really
group any data. Using the NewPage property of the subreport's title band
makes the title print on one page, then a page break, and the subreport's
detail band print on the next page.

I'm using RB 6.03. I'm sure there is an easy way to implement this
little feature, but I can't seem to find it.

Erik

Comments

  • edited March 2003
    Groups aren't going to help in the main report, because the detail band only
    prints once and prints the subreports inside of it.

    One solution to this problem is to daisy chain them together by placing each
    subreport in the summary band of the above subreport.

    One thing you can try is to use section style subreports, but toggle their
    visibility property in the main report's DetailBand BeforePrint event when a
    subreport has no data in its data pipeline. Check for ppdaNoRecords in the
    DataPipeline.State set property.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Jim Bennett (Digital Metaphors) wrote:

    I tried this and it seems that when the outer/enclosing subreport has no
    records, none of the subreports nested in its summary seem to print. Is
    this expected, or am I mistaken?

    I also noticed a bug with cut/paste of subreports. Cutting a subreport
    from the summary of one subreport back to the main report that has no
    summary band causes an AV. This happens in a simple test report with no
    data pipelines attached in 6.03 for me:
    ---------------------------
    Error
    ---------------------------
    Access violation at address 03F2E2E8 in module 'rbRCL66.bpl'. Read of
    address 000000EC.
    ---------------------------
    OK
    ---------------------------


    I tried this as well. The first visible subreport has to be pbChild, so
    there isn't a blank page at the beginning of the report. The subsequent
    printing pbSection subreports are somehow overlaid on top of each other,
    sharing the same page, instead of printing one at a time with page breaks
    between each subreport. I thought it might be related to ShiftRelativeTo,
    but that property doesn't make much sense for a pbSection report, and
    setting that appropriately doesn't seem to make a difference here.

    Is there a way to manually/in-code place a blank component in the summary
    of the subreports that expands to fill the rest of the page, to force a new
    page? That way, I could continue to use normal pbChild subreports (and
    inherit the main report's title band, etc.).

    Printing the four subreports all as pbChild subreports works fine - it
    just doesn't have page breaks between subreports like I need. I'd suggest
    a feature to make it easier to add page breaks after a subreport - the
    current workarounds/methods seem a bit complex and error-prone in 6.03 (at
    least in my experience).

    Erik
  • edited March 2003
    > Printing the four subreports all as pbChild subreports works fine - it

    I managed to get this working by creating a fake group (grouping in a
    variable that is never set and never changes) in the subreports, and adding
    what I had in the subreport's title to the group header, so I get a header
    that prints without a page break before the detail. Then I could set the
    title band's NewPage property dynamically at runtime based on whether it
    was the first subreport to print or not, to cut out the initial blank page
    that always setting NewPage produced.
    The process I went through still seems like an enormous amount of
    searching/work required for a fairly simple feature, and requires careful
    documenting of the various hacks so others can understand the code later.
    If I haven't missed something obvious, my feature request still stands. :)

    Erik
  • edited March 2003
    Yes, that works. I came up with a fake group approach in a subreport earlier
    this morning before I read your post and thought I had a great idea, but you
    beat me to it:) I have a couple twists on it. For the extra group variable,
    you can set it to not be visible in the report, so that it isn't displayed,
    but can be used for the group, or even a static invisible TppLabel. I then
    toggled the NewPage property of the group object directly in order to force
    the page break in the main reports DetailBand.BeforePrint event. Here is an
    example (I used DADE for the data access):

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

    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.