QuickReports keep text together

rogerfg7 used Ask the Experts™
We have an address field that we do not want to break over columns or pages.  How can we make a child band or a subdetail band print within a column or page?

QR v 3.6.2, Delphi 6
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior developer, analyst and customer assistance
(I hope to have right understood the Q.)

In a report of mine I check for the available space before to print the column and if it is less than required I force a newpage.

Something like this

procedure TForm1.ColumnHeaderBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
  Needed: extended;
  DetailBand.ExpandedHeight(Needed); //get the height required by the detailband
  Needed := Needed+Sender.Height; //add the columnheader height
  if Needed > QuickRep1.availablespace then
//There is no more space in this page? Let's print on a new page

I can at least help you provide the details to allow the experts to answer your question.  You mention that, "We have an address field that we do not want to break over columns or pages".  Is this truly one field?  Or is it several fields comprising one address?  If it is one database field, could it contain carriage return line feed characters so it would need to be printed on multiple lines?  What is causing the issue?  Is it the width or the height that is causing the issue?  Can you give us an example of 1) the text causing the issue (with the field names you get it from) and 2) an example of the report format that will show us the error the text is causing?

With this information we might be able to help you out.  Let us know.


The report consists of a list of UK Carehome Group companies with a sub-detail list of Carehomes within each Group.

An address consists of a number of database fields concatenated using a comma and space into a single calculated 'FULL_ADDRESS' field which is then displayed in a TQRDBText field (have also tried TQRMemo field).  We have a master/ sub-detail report which has an address field in the master held in a TQRChildBand and also multiple records with addresses in the Sub-detail band.

The master record child band has just a TQRLabel, caption'Address' followed by a TQRDBText displaying the address.

The sub-detail band has a TQRDBText with the Name of the carehome and another TQRDBText on the same line displaying the number of beds in the home.  Underneath that is a TQRDBText field with the home address.  This will normally fit on one line, but occasionally spreads over 2 lines.


Sorry, hit the return key and it submitted the comment.

Further information.  There are no carriage returns embedded within the calculated FULL_ADDRESS field.  We rely on word-wrap to wrap the text as required onto multiple lines.  However when the address prints over more than one line we want the whole address to be contained within a column and not split over separate columns / pages. Ideally within the subdetail band we would like the ORGANISATION / TOTALBeds and FULL_ADDRESS to be not split over a column.  As a further refinement, we would also like the UK postcode e.g. LE8 6JJ not to split over a line.  In MS Word we can have 'Keep lines together' and 'Keep with next' paragraph properties and hard (non-breaking) spaces.  We would like to have a similar facility within QuickReports



Your solution worked, with a bit of adjusting.  Many thanks.  Now, how do I award you the points?
Ferruccio AccalaiSenior developer, analyst and customer assistance

Glad to have helped you.
Got the points, so you found this answer too :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial