Hide Header if its Subreport Has No Records (A2002)

D

David

We have a report that lists employees assigned to each department. The
report is grouped by department name, and contains a department_name header,
which contains a subreport of employees. The main report lists all
departments. Is there a way to hide the department if the subreport contains
no employees for that department? More generally, is there an easy way to
hide a report header if the subreport in that header contains no records,
even when the report header has a record (like a department)?
Thanks for your help,
David
 
A

Allen Browne

Use the HasData property of the report in the subreport.

For example, you could set the Control Source of your text box to:
=IIf([NameOfYourSubreportControlHere].[Report].[HasData], [DeparmentName],
Null)

Be sure to change its Name property as well: Access gets confused if the
text box has the same name as a field, but is bound to something else.

If you need something more powerful, it is possible to programmatically set
the Visible or PrintSection and MoveLayout properties of a section in its
Format event.
 
D

David

Thank you Allen. I'll try your recommendations.

Allen Browne said:
Use the HasData property of the report in the subreport.

For example, you could set the Control Source of your text box to:
=IIf([NameOfYourSubreportControlHere].[Report].[HasData], [DeparmentName],
Null)

Be sure to change its Name property as well: Access gets confused if the
text box has the same name as a field, but is bound to something else.

If you need something more powerful, it is possible to programmatically set
the Visible or PrintSection and MoveLayout properties of a section in its
Format event.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

David said:
We have a report that lists employees assigned to each department. The
report is grouped by department name, and contains a department_name header,
which contains a subreport of employees. The main report lists all
departments. Is there a way to hide the department if the subreport contains
no employees for that department? More generally, is there an easy way to
hide a report header if the subreport in that header contains no records,
even when the report header has a record (like a department)?
Thanks for your help,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top