On NoData

mderby

Registered User.
Local time
Tomorrow, 02:09
Joined
Apr 14, 2003
Messages
41
Hi,

I have a report rptASof which has a subreport named rptSubAsof.
The issue here is that I don't want to print the report when there is no data in the report.

I try to put this in the On NoData event of the rptASof:

Private Sub Report_NoData(Cancel As Integer)
Msgbox "No Data"
Cancel = True '(Correct)
End Sub

But this error pop up when i try to run it :

"Object invalid or no longer set" and the whole program hangs.

Will someone point me to the correct way please ?

Thanks
 
On No Data Error

If you're opening the report from code behind a form, you need to handle the error that's generated as a result of the following code.

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data"
Cancel = True
End Sub

Add the following Error handler;

Private Sub TestNoData_Click()
On Error Resume Next
DoCmd.OpenReport "SomeReport", acViewPreview
If Err = 2501 Then Err.Clear
End Sub

Put these two lines of code on either side of the DoCmd.OpenReport..in your form.

IC
 

Users who are viewing this thread

Back
Top Bottom