HasData property used to hide a subreport

C

chris klein

I posted an earlier msg asking about how to apply the
HasData property and have learned that one can use it to
set the visible property, by placing

Me!SubReportControl.Visible =
Me!SubReportControl.Report.HasData
into the OnFormat event of the section of the main report
where the subreport appears.

However, I find that the subreport is still visible, even
though all of the fields displayed by the subreport are
empty (and/or null). I suspect that this might be caused
by the fact that the subreport is based on a table that is
linked to the table of the main report by an ID field, and
so there is a recordset for the subreport, except that the
ONLY field of that recordset that contains any data
(except perhaps null) is the ID field. ID is not
displayed by the subreport, but it would seem that its
presence causes HasData to be True rather than false, so
the blank subreport is visible.

If this is correct, is there any way around it? If not,
any other strategies?
Thanks
C Klein
 
B

Bruce M. Thompson

Reply below.
I posted an earlier msg asking about how to apply the
HasData property and have learned that one can use it to
set the visible property, by placing

Me!SubReportControl.Visible =
Me!SubReportControl.Report.HasData
into the OnFormat event of the section of the main report
where the subreport appears.

However, I find that the subreport is still visible, even
though all of the fields displayed by the subreport are
empty (and/or null). I suspect that this might be caused
by the fact that the subreport is based on a table that is
linked to the table of the main report by an ID field, and
so there is a recordset for the subreport, except that the
ONLY field of that recordset that contains any data
(except perhaps null) is the ID field. ID is not
displayed by the subreport, but it would seem that its
presence causes HasData to be True rather than false, so
the blank subreport is visible.

Change the record source for the subreport to an sql statement based on the
source table and enter criteria of "Is Not Null" in any of the fields that you
don't want to be empty when you are viewing your report. This will cause the
recordcount of the subform to be zero when no records meet the given criteria
and the "HasData" property will then be False.
 

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