• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

Another QReport Question... Keeping stuff together


I havea group in my report (header - sub detail - footer) and I NEVER want them to be separated over two pages..
Now I tried the Footer.Linkband = Header it didn't work
I tried Footer.linkband = Detail and Detail.LinkBand = Header. didn't work too..

What do I try next?

  • 3
  • 2
1 Solution
mmm, i'm not sure but can reprintonnewpage not help you? ie. that the header is reprinted on the other page.

Otherwise, you've to use NewPage to be sure that you always start a newpage.

lizzzardAuthor Commented:
Hi, Zif

Ehr.. I don't want to REprint it.. I just want it to print once.. as a group.. So if the  Header - Detail - Footer combo doesn't fit on the page, THEN it has to go to a new page...
Ofcourse, I can calculate how much space is left and how much space I need, but I gather QReport has to do it by itself if I want too...

mmm, don't know if this is possible in QR.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

You right, you need to write BeforePrint method for your groupheader. There you need to calculate detail section size. If it's not possible to finish section before end of page, then you must start new page manually. QR can't do it itself.

hey lizzzard,

I read something on how to implement a widow/orphan feature in QR :

There is no support for a Window/orphan feature, but you can do this with some minor code.
There is a function in the report called AvailableSpace that returns the amount of space left on the page.  You can compare that value to the band's Size.Length property and call NewPage when There is not enough space for the band.  AvailableSpace is a protected function so you can not call it directly.  If you subclass the report, you can access the function by casting the report to the subclass.
First, add the following declaration in the type section of your report form declaration:
  TMyQuickRep = class(TQuickRep)

To use this function to keep a band from being split over a page:
procedure Tfrm.DetailBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
  if TMyQuickRep(QuickRep1).AvailableSpace >= round(Sender.Size.Length) then

lizzzardAuthor Commented:
Thanks, Zif

Sorry for the delay.. I used something like you proposed.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now