access subreports when data is null

Posted on 2012-08-22
Medium Priority
Last Modified: 2012-08-23

I have a report, that contains multiple subreports.  I want the subreports to disappear when there is no data.  How do I accomplish this?

of note, inside the subreport there is also a count(*) textbox which will report "0" if no data exists.  I do not know if that makes a difference.

Question by:Evan Cutler
LVL 26

Accepted Solution

Alan Warren earned 1400 total points
ID: 38323760
Hi arcee123,

Try adding this to the detail_format event of the main report

Open in new window

Obviously need to change the name of the sub report to your sub report names or containers if different from sub report.

Alan ";0)
LVL 77

Assisted Solution

peter57r earned 600 total points
ID: 38323789
For  the section of the main report that contains the subreport, use the section's format event procedure to test for data in the subreport...

If me.NameOfSubReportContainerControl.Report.HasData Then
     me.NameOfSubReportContainerControl.Visible = True
     meNameOfSubReportContainerControl.Visible = False
End if

Note that NameOfSubReportContainerControl is the name of the control on the main form that contains the subreport.  It is not (except by coincidence) the name of the subreport.

You can set the Can Shrink property of the main report section to Yes if you want to recover the space (and there is nothing else below the subreport in the section)

Author Closing Comment

by:Evan Cutler
ID: 38325523
Thanks Guys.

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question