hiding empty subreports

C

chris klein

Access 2002 HELP says that I can hide a subreport from
being shown in print preview or from being printed if it
contains no data, by using the HASDATA property, i.e.:

"You can use this property to determine whether to hide a
subreport that has no data. For example, the following
expression hides the subreport control when its report has
no data.

Me!SubReportControl.Visible = Me!
SubReportControl.Report.HasData"

However, I don't understand WHERE to place this expression
and how to cause it to be activated. Anyone know?
Thanks
 
M

Marshall Barton

chris said:
Access 2002 HELP says that I can hide a subreport from
being shown in print preview or from being printed if it
contains no data, by using the HASDATA property, i.e.:

"You can use this property to determine whether to hide a
subreport that has no data. For example, the following
expression hides the subreport control when its report has
no data.

Me!SubReportControl.Visible = Me!
SubReportControl.Report.HasData"

However, I don't understand WHERE to place this expression
and how to cause it to be activated.

Place it in the Format event procedure of the section
containing the subreport.
 
C

chris klein

I've just tried this, but without success. I added the
following to the On Format Event of the Detail section
(which is where the subreport appears):

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If FormatCount = 1 Then
Me![T131/6-Land subreport].Visible = Me![T131/6-Land
subreport].HasData
End If
End Sub

But this produces Run time error 2465.......database can't
find the field 'T131/6-Land subreport' referred to in your
expression

Any help on what I'm doing wrong would be greatly
appreciated. Thanks
 
M

Marshall Barton

chris said:
I've just tried this, but without success. I added the
following to the On Format Event of the Detail section
(which is where the subreport appears):

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If FormatCount = 1 Then
Me![T131/6-Land subreport].Visible = Me![T131/6-Land
subreport].HasData
End If
End Sub

But this produces Run time error 2465.......database can't
find the field 'T131/6-Land subreport' referred to in your
expression

That's a pretty wierd name, are you sure it's the name of
the subreport *control*, which might be different from the
name of the report it's displaying?
--
Marsh
MVP [MS Access]


 
S

SA

The other way to do this and not leave a blank space on the main report is a
bit more simple and that is to make sure your sub report has its can grow
property set to true and then set its height to .0007

The other problem with Chris' code is in the second line he's missing a
qualifier on the sub report it should read

Me![T131/6-Land subreport].Visible = Me![T131/6-Land
subreport].Report.HasData

--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

Marshall Barton said:
chris said:
I've just tried this, but without success. I added the
following to the On Format Event of the Detail section
(which is where the subreport appears):

Private Sub Detail_Format(Cancel As Integer, FormatCount
As Integer)
If FormatCount = 1 Then
Me![T131/6-Land subreport].Visible = Me![T131/6-Land
subreport].HasData
End If
End Sub

But this produces Run time error 2465.......database can't
find the field 'T131/6-Land subreport' referred to in your
expression

That's a pretty wierd name, are you sure it's the name of
the subreport *control*, which might be different from the
name of the report it's displaying?
 
M

Marshall Barton

SA said:
The other way to do this and not leave a blank space on the main report is a
bit more simple and that is to make sure your sub report has its can grow
property set to true and then set its height to .0007

The other problem with Chris' code is in the second line he's missing a
qualifier on the sub report it should read

Me![T131/6-Land subreport].Visible = Me![T131/6-Land
subreport].Report.HasData

Good catch Steve, I completely missed it.
 

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