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

Forcing a page break within a group

edited March 2016 in General
Hi,

I have a situation where I'm printing a report from a dataset, and I
want to manually force where a pagebreak occurs.

My reports structure (*prior* to attempting the page break) is as follows:

- Report Header
- Group1 Header
- Detail Band
- Group1 Footer
- Page Summary


I want to be able to insert page breaks depending on a value of the
detail band - completely independent of Group1

Initially I thought to use another Group, with a 'StartNewPage' set to
True, and manually set the OnGetBreakValue. Thus the report looks like this:


- Report Header
- Group1 Header
- Group2 Header
- Detail Band
- Group2 Footer
- Group1 Footer
- Page Summary


However the problem I have is that the pagebreak now occurs even if I
never change the value in the OnGetBreakValue event - simply the
changing of Group1 also causes Group2 to reset at the same time,
triggering the page break.

I can't swap Group2 and Group1's positions around, as I may want to
force the pagebreak half way through Group1 in some instances.

Is it possible to stop Group2 from pagebreaking when Group1 rolls over,
even though Group2 is closer related to the detail band?

Or is there a better way to achieve this?

Thanks & Regards

Adam.

Comments

  • edited March 2016
    Sorry - I should have added I'm using Reportbuilder 15.05 on Delphi XE2
  • edited March 2016
    Hi Adam,

    The design you have is more of a "nested" group structure rather than
    two separate groups working independently as you need. If you need to
    use an individual group for breaking pages, you may need to move it (as
    well as the relevant data) to a subreport.

    Have you tried using the TppPageBreak component? You can toggle its
    visibility based on the detail band's value so it will only break to a
    new page in certain cases. This may be a simpler solution than using
    multiple groups.

    Best Regards,

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



    Thanks for your reply.

    I did try using a TppPageBreak component, but for some reason I was
    getting some access violations occur part way through the report. I
    wasn't able to figure out why - the code was very basic and it was just
    turning visibility on and off.

    However I believe I’ve found a solution:

    I've found if I set ppGroup2’s NewPage property to false at design time,
    and then within the OnGetBreakValue set whether I want it visible or not
    each time it fires such as the below it works:

    procedure TMyReport.ppGroup2GetBreakValue(Sender: TObject; var
    aBreakValue: string);
    begin
    ppgroup2.NewPage := false;
    if then
    begin
    ppgroup2.NewPage := true;
    Changevalue(abreakvalue);
    end;
    end;


    This way by default ppGroup2’s newpage is set to false so it won’t force
    a new page to print when ppGroup1 breaks as well – and I just set
    NewPage to True when I know I need to use it.

    This saved me using a subreport - however I will keep that trick in mind
    incase I run into any trouble.

    Thanks again for your help.

    Best Regards

    Adam.
This discussion has been closed.