Subreport NoData event

  • Thread starter Thread starter Kitty
  • Start date Start date
K

Kitty

I have the following code in the NoData event of a
subreport. It prints a message that there were no records
to report.

The message works fine when I open the subreport by
itself. When I open the "master" report, the message does
not appear.

There are three subreports in the master report. I want a
message to appear when no records meet the criteria for
the sections versus the sections appearing blank - I want
the reader to know for sure there is no data versus
wondering if the report is working correctly.

Suggestions?

Thanks for your help. Kitty

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData
Me![lblNoData].Visible = True
[lblNoData].FontSize = 10
Exit_Report_NoData:
Exit Sub
Err_Report_NoData:
MsgBox Err.Description
Resume Exit_Report_NoData
End Sub
 
Kitty said:
I have the following code in the NoData event of a
subreport. It prints a message that there were no records
to report.

The message works fine when I open the subreport by
itself. When I open the "master" report, the message does
not appear.

There are three subreports in the master report. I want a
message to appear when no records meet the criteria for
the sections versus the sections appearing blank - I want
the reader to know for sure there is no data versus
wondering if the report is working correctly.


AFAIK, subreports with no data do not process any events.
The way to get your message displayed is to place a text box
or label in the main report in the same position as the
subreport control. Then use code in the section's Format
event to show or hide the two controls:

Me.subreport.Visible = Me.subreport.Report.HasData
Me.labelmsg.Visible = Not Me.subreport.Report.HasData
 
Back
Top