QuickReport: Prevent detail band printing if subdetail empty

Greetings,

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.

Thanks,

Robert Lancaster

PS: I am an old hand at programming but a child in arms when it comes to Quick Reports :)
LVL 1
RLancasterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
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 ;-)
0
gdebiasaCommented:
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.

Glen
0
GreymanCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RLancasterAuthor Commented:
You get 50 bonus points for a good answer and for me taking so long to grade the question !!! :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.