SubReport No Data printing problem

T

Tony_VBACoder

With Access 2002, I have a SubReport with items listed in
a grid-like format. This subreport is linked to a field
on the Main Report. The problem I have is, when the
SubReport has no data to link to, I get a blank area on my
Main Report, where the subreport is supposed to be. To
work around this, I created a dummy un-bound subreport
with a grid-like layout (4 blank rows) of unbound text
boxes and some horizontal and vertical lines, so that I
get some blank rows to appears. I placed my dummy
subreport behind my Bound-subreport at the same Top
position as my bound-subreport, so that when the bound-
subreport has no data, the dummy subreport will show
through. The problem is, my bound-subreport moves below
my dummy subreport, leaving a large gap in my Main Report.

Is there a way that I can determine if my Bound-subreport
has any data, that way I can set the Top property of my
dummy subreport to be at the same position as my bound-
subreport? I know I can use the RecordsetClone for a
SubForm, but how can I use this for Report?
 
M

Marshall Barton

Tony_VBACoder said:
With Access 2002, I have a SubReport with items listed in
a grid-like format. This subreport is linked to a field
on the Main Report. The problem I have is, when the
SubReport has no data to link to, I get a blank area on my
Main Report, where the subreport is supposed to be. To
work around this, I created a dummy un-bound subreport
with a grid-like layout (4 blank rows) of unbound text
boxes and some horizontal and vertical lines, so that I
get some blank rows to appears. I placed my dummy
subreport behind my Bound-subreport at the same Top
position as my bound-subreport, so that when the bound-
subreport has no data, the dummy subreport will show
through. The problem is, my bound-subreport moves below
my dummy subreport, leaving a large gap in my Main Report.

Is there a way that I can determine if my Bound-subreport
has any data, that way I can set the Top property of my
dummy subreport to be at the same position as my bound-
subreport? I know I can use the RecordsetClone for a
SubForm, but how can I use this for Report?


Report objects have a HasData property that can take care of
this issue. Add code to the Format event procedure of the
main report section that contains the subreports to make the
appropriate subreport control visible or not.

Dim bolData As Boolean
bolData = Me.boundsubreportcontrol.Report.HasData
Me.boundsubreportcontrol.Visible = bolData
Me.unboundsubreportcontrol.Visible = Not bolData
 

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