[Webinar] Streamline your web hosting managementRegister Today

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

QuickReport: Prevent detail band printing if subdetail empty


How can I prevent a detail band from printing if its associated subdetail band (in a master/detail report) is blank. In the sub detail band I can set its PrintIfEmpty to FALSE but the detail band stays there and it looks kinda silly especially if I want to print each master record and its associated data on a new page.


Robert Lancaster

PS: I am an old hand at programming but a child in arms when it comes to Quick Reports :)
1 Solution
hi RLancaster,

don't know how you do it, but have you tried to make a query which contains all the fields from master and detailtable.

then make a group-band for the masterpart, and in the detail-band drop the other fields, to prevent that the detailband is printed, just assign a before-print procedure where you can check self if there anything to print and set the desired boolean-var print-band to true or false.

i guess there are, also other possibilities to do that.

meikl ;-)
meikl has the right approach.

In the group band, use the OnBeforePrint to check the query for the detail band. If the query has no records (EOF = true or a similar test), then set the AllowPrint variable (not sure of the name, but it is a parameter of the OnBeforePrint method) to false.

This should suppress the header band when the detail band has no records.

As an alternative, you can drop a band onto the Quickreport, and set it as a header for the subdetail band.

Subdetail headers never print if there are no subdetail entries printing, and the subdetail header will print only once until the master dataset goes to the next record.

If your detail band is the main detail band for the report, you can still do as I suggested, and either set PrintBand to false in the OnBeforePrint (PrintBand is the actual name of the AllowPrint variable), or simply set the height to Zero.
RLancasterAuthor Commented:
You get 50 bonus points for a good answer and for me taking so long to grade the question !!! :)

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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