hiding empty subreports

  • Thread starter Thread starter chris klein
  • Start date Start date
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
 
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.
 
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
 
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]


 
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?
 
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.
 
Back
Top