Hiding a sub-report when empty

B

Bigger

Hi all!
I have in my application (Access 2003, Win XP) a report with a subreport. I
would like not to display the subreport when it contains no data. What is the
code to use and in which event?
Please help.
Many thanks.
 
J

John Spencer

If I recall correctly, in the format event of the section that has the
subreport control, you would use something like

IF Me.NameOfSubReportControl.Report.HasData then
Me.NameOfSubReportControl.Visible = True
else
Me.NameOfSubReportControl.Visible = False
End IF

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
M

Marshall Barton

Bigger said:
I have in my application (Access 2003, Win XP) a report with a subreport. I
would like not to display the subreport when it contains no data. What is the
code to use and in which event?


Subreports with no data do not display anything so there
should be nothing to hide. If you want to reclaim that
space on the page, set the subreport control and its
section's CanShrink property to Yes.
 
B

Bigger

Thank you John and Marshall for your reply.
Marshall is right, the subreport dos not display when it is empty. I can't
fogure out what I was doing for it to display. I used the code provided by
John with a label that I wanted to show with the subreport.
Thanks again and sorry for the annoyance this might have caused.
 

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