Home Subreports

How to detect if OnStartPage is printing a subreport

edited April 2013 in Subreports

D7E, RB14.08.

I have a situation where a subReport is set in a region that takes up
an entire page. The sub report is in GroupFooterBand3 of the main
report.

This is a two-pass report.

In ppReport.OnStartPage, I need to determine if I'm printing the 'main'
part of the report, or if this is a StarPage for the group footer -
which will do different logic based on the fact that I'm now printing
the subreport.


That is, I've logged "event firing" order as:

ppReportStartPage (printing main)
GroupHeaderBand1BeforePrint
GroupHeaderBand2BeforePrint
GroupFooterBand1BeforePrint
GroupFooterBand3BeforePrint (sub)
ppReportStartPage (printing sub)
GroupFooterBand3BeforePrint (sub)
ppChildStartPage
ppReportStartPage (printing main)
GroupHeaderBand1BeforePrint
GroupHeaderBand2BeforePrint
GroupFooterBand1BeforePrint
GroupFooterBand3BeforePrint (sub)
ppReportStartPage (printing sub)
GroupFooterBand3BeforePrint (sub)
ppChildStartPage


I need to know when ppReportStartPage triggers for the start of the
SubReport as opposed to the main report.

I can set flags in the events, but wonder if there's a better "RB" way?

Thanks.

EdB

Comments

  • edited April 2013
    Hi Ed,

    The ChildReport.StartPage event will fire with the subreport starts,
    then each subsequent page break.

    If the subreport is inside the GroupFooter Band, you could simply use
    the GroupFooter.BeforePrint to determine when the subreport will begin
    printing.

    Best Regards,

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

    I'm not entirely sure what you mean by "simply use the
    GroupFooter.BeforePrint to determine when the subreport will begin
    printing."

    Right now, in the group footer beforeprint, I'm already controlling
    visibility.

    That is, I do
    ppSubReport1.Visible := ;

    The footer BeforePrint gets called multiple times before the subReport
    actually does any printing (that is, I might be setting visible:=true,
    but the event is fired without actually performing a print).

    Assuming .visible is true, how am I to determine that the ppSubReport
    is actually in the 'printing' phase?

    EdB


  • edited April 2013
    Is the subreport the only item inside the region? If so, couldn't you
    use the Region.OnPrint event to determine when the subreport starts?

    I'm still not quite clear how your report is designed but as you
    mentioned in your first post, it may be necessary to assign flags in the
    subreport events to let the rest of your app know the subreport is printing.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2013
    The report prints a manufacturing work order, and a drawing (sound
    familiar? ).

    The main report has a group on work order no. It has a group header and
    footer. The subreport is the only object in the group header, the group
    footer is 'empty' (height=0).

    At run time, the user decides if the drawing should be printed before
    or after the main work order (I assign the subReport to the footer if
    "after").

    The main report is portrait mode, the drawings are landscape - so far
    everything has been going great - I can toggle between
    landscape/portrait without any issues on (so far) every printer I've
    come across.

    I also have a (new) requirement of setting duplex mode. I'm trying to
    figure out the best place to check duplex type - ie set dupemode to
    none, hor or vert mode depending on whether printing main report,
    subreport, or blank page (hopefully skipped - I've posted in another
    thread about this) in subreport.

    Right now I'm using flags to control things - but not very elegant.

    It sounds like you'd suggest I drop a region into the header, move the
    subreport into the region, and then reassign the region to
    header/footer depending on whether drawing should print before/after
    main report.

    Right now I have events in ppReportStartPage and ppSubReportStartPage -
    it isn't clear to me that moving the subreportStartPage code to
    RegionBeforePrint (or OnPrint) will help - it might be "too late" to
    set duplex (or eject page) at that point.

    In a typical scenario (drawing after page, subReport assigned to group
    footer)


    [grp header height=0]

    [main report
    .PageStart=set duplex mode

    ]

    [grp footer
    .BeforePrint - set subReport visibility
    [subReport
    .StartPage - ppChildReport1.Engine.Page.PrinterSetup.Duplex:=

    ]
    ]



    EdB

  • edited April 2013
    Hi Ed,


    Sorry no, in your initial post you mentioned that you had a subreport in
    a region. I assumed you were already using a TppRegion.

    Honestly if I were doing this, I would also use the "non-elegant" flag
    method. As you have seen, getting the timing correct for subreport and
    main report events can be tricky at times.

    As for your duplex issue, you will likely have to send PCL commands to
    adjust duplexing during generation. We will address this in the other
    thread.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.