Home Subreports

Handling subreport blank page

edited February 2006 in Subreports
Hi folks,

I have a report with no main report and two section subreports (thanks for
the design help Nico). If I do nothing, when there is no data in the second
subreport, the printout ends with a blank page. From the help, I'm led to
believe that it should not create a blank page, but I understand from other
recent posts that there is a workaround, which is to check for data in the
main report DetailBand.BeforePrint event, so here's what I did:

procedure TMain.CrzRptDetailBandBeforePrint(Sender: TObject);
begin

if (CrzLoiterPipe.RecordCount > 0) then
CrzRptSubLoiter.Visible := true
else
CrzRptSubLoiter.Visible := false;

end;

When I do this, and there is no data in the second subreport, it prints
without the blank page, just dandy. But if there is data, when I do a
preview, the second subreport doesn't render, I'm just left forever with the
hourglass cursor and I have to close the window to stop. If I comment out
the code in the above event handler, it works fine if there is data, and if
there is no data, it prints a blank page.

Delphi 7, RB 10.0.

Any ideas?

Thanks,
Van Swofford
Tybee Jet Corp.

Comments

  • edited February 2006
    Upon further investigation.....

    The problem only shows up if multiple reports are generated during one
    execution of the program. Examples:

    1. First report has no data for the second subreport. This works fine, and
    there is no blank page. Next, run another case which generates data for
    display in the second subreport and preview the report. The first subreport
    prints fine, but selecting the page with the second subreport gets a blank
    page on the screen and a never-ending hourglass cursor. Close the preview
    window and rerun the first report and it works fine.

    2. First report has data for the second subreport. This works fine, and
    prints the second subreport as expected. Next, run another case that does
    not generate data for the second subreport and preview the report. The
    first subreport prints fine, but has a next page button. Click the next
    page button and a blank page displays, and there is still a next page
    button. Click the next page button again, and see a blank page with a
    never-ending hourglass cursor. Close the window and rerun the first report
    and it works fine.

    So, it appears that it isn't so much whether the subreport's visible
    property is set to true or false, but that running another report that
    results in changing the visible property is causing the problem. Seems like
    it's happy with whatever the visible setting is the first time the report is
    run, but doesn't like it being changed to the other setting. How it's doing
    that is beyond me.

    Thanks!
    Van
  • edited February 2006
    Hi Van,

    I have not seen this behavior before however I believe it may have something
    to do with the timing of setting the subreport's visible property. As a
    test, try toggling the visibility of the second subreport in an earlier
    event, such as the Report.BeforePrint or even before you make a call to
    Report.Print. If the problem persists, please send a small example I can
    run on my machine that demonstrates this behavior in .zip format to
    support@digital-metaphors.com and I'll take a look at it for you. Also, I
    recommend upgrading to the latest version (10.01).

    --
    Regards,

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

    Best Regards,

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

    You're a genius! I moved the setting of the visible property to before the
    report is printed, and it works like a champ. I did try it in the
    report.beforeprint event, and it was the same as previously reported. I
    guess it is a timing issue. Just got the download email, so I'll get that
    installed here in a bit.

    Thanks a bunch!
    Van

This discussion has been closed.