Trouble hiding subreport

S

S Kahn

I have a report (rptA) with two subreports (srptA1 and srptA2). I have set
the properties of both to 'Can Shrink' including those of the fields shown on
the subreports. The subreports are hidden when the fields are blank.
However when srptA1 is invisible, srptA2 still shows below the space
occupied by srptA1 even though srptA1 is invisible. How can I have srptA2
move up vertically so that a large gap is not left on the report when srptA1
is blank.
Any help would be greatly appreciated. Thanks in advance.
SK

PS: Please note I am an amateur programmer.
 
A

Allen Browne

There should be no need to hide these subreports (i.e. you should not have
toggle their Visible property.)

1. Open the main report in design view.

2. Right-click the edge of the first subreport control, and make sure its
Can Shrink property is Yes. Repeat for the second one.

3. Click the Section that contains these reports (Detail?), and make sure
the section's Can Shrink is also set to Yes.

4. Make sure the subreports are not overlapping each other, and that no
other control is overlapping them vertically (not even partially beside
them.)

Now, both reports should shrink to zero-height when they have no data, and
the section itself should shrink as well.
 
S

S Kahn

Thanks a lot, works great.
SK

Allen Browne said:
There should be no need to hide these subreports (i.e. you should not have
toggle their Visible property.)

1. Open the main report in design view.

2. Right-click the edge of the first subreport control, and make sure its
Can Shrink property is Yes. Repeat for the second one.

3. Click the Section that contains these reports (Detail?), and make sure
the section's Can Shrink is also set to Yes.

4. Make sure the subreports are not overlapping each other, and that no
other control is overlapping them vertically (not even partially beside
them.)

Now, both reports should shrink to zero-height when they have no data, and
the section itself should shrink as well.
 
S

Sietske

Hi all,

How do I hide the label of a subreport when the subreport shows no data?

I've tried using

Me.lblSubreportName.Visible = IsNull(Me.subreportName)

because

Me.lblTextboxName.Visible = IsNull(Me.txtTextboxName)

worked perfectly well for hiding labels of empty textboxes. But it appears
that this method does not work for reports. What could I do to solve this
problem?
 
J

John Spencer

Try using the hasdata property of the subreport

Me.lblSubreportName.Visible = Me.subreportName.HasData

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
S

Sietske

Thank you!

John Spencer said:
Try using the hasdata property of the subreport

Me.lblSubreportName.Visible = Me.subreportName.HasData

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
S

Sietske

In my situation, I needed to add "Report" in the code to get it working:

Me.lblSubreportName.Visible = Me.subreportName.Report.HasData

But it works very well now, thanks again!
 

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