L
Leslie Isaacs
I want to stop a report from printing if there is no underlying data.
I have set the report's OnNoData event to Cancel=True, and this seems to
work fine, but I see on the AccessWeb (at
http://www.mvps.org/access/reports/rpt0006.htm) the following:
However, if you're opening the report from code behind a form, you need to
handle the error that's generated as a result.
'*********** Code Start ************
Private Sub TestNoData_Click()
On Error Resume Next
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear
End Sub
'*********** Code End ************
I don't understand this - what is the error that is generated, and why? With
my report I'm not aware that any error is being generated - or am I missing
something.
Any help would be appreciated.
Leslie Isaacs.
I have set the report's OnNoData event to Cancel=True, and this seems to
work fine, but I see on the AccessWeb (at
http://www.mvps.org/access/reports/rpt0006.htm) the following:
However, if you're opening the report from code behind a form, you need to
handle the error that's generated as a result.
'*********** Code Start ************
Private Sub TestNoData_Click()
On Error Resume Next
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear
End Sub
'*********** Code End ************
I don't understand this - what is the error that is generated, and why? With
my report I'm not aware that any error is being generated - or am I missing
something.
Any help would be appreciated.
Leslie Isaacs.