Report OnNoData event

NOL

Registered User.
Local time
Today, 04:24
Joined
Jul 8, 2002
Messages
102
Hi,

I want to cancel opening of a report if it has no data.
I've tried the suggestions on the forum viz. use macro with msgbox & cancel event / use VBA code with cancel = true

No matter what I do ( on error resume next , error trapping, set warnings) I still get the message :
"OpenReport action was cancelled "

I want to get rid of this message .
any help will be great !

Thanks,
Gina.
 
Add this to the On No Data Event of the Report

MsgBox "There is no data for this report. Canceling report...", , G_AppTitle
Cancel = -1

HTH:D
 
Hi ,
Thanks for the suggestion.
But I still get the same message ..
what is your code supposed to be doing ?

Thanks,
Gina.
 
Gina:
Where are you putting the code?? In the report or in a Macro??
 
In the report ..

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report...", , G_AppTitle
Cancel = -1
End Sub


I have tried using macro too ..
 
Try this for giggles....


Private Sub Report_NoData(Cancel As Integer)
On Error goto ErrRpt
MsgBox "There is no data for this report. Canceling report...", , G_AppTitle
Cancel = -1
ErrRpt
If Err.number = 0 then
Else
End if
End Sub

Let me know.
 
that no work either .

I first get the message There is no data for this report. Canceling report..."
when i clik on OK i get the next message viz. " The OpenReport Actin was cancelled"

I even tried putting a msgbox in the on error event property of teh report .. doesn't even go there .
 
Private Sub Command33_Click()
On Error GoTo Err_Command33_Click DoCmd.OpenReport "Invoices", acNormal, "", "IsNull([fldPrDate])"

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
If Err = 2501 Then
Resume Exit_Command33_Click
Else
MsgBox Err.Description
Resume Exit_Command33_Click
End If

End Sub
 
YIPPEE!

The error trapping code in the form which opens the report,
along with the Cancel = true in the OnNOData event did it !
And to think I'd thought I'd finally learnt where to look !

Dugantrain , yes I'd tried Setwarnings , but that doesn't work, in this case ...

Thanks guys !!

Gina
 

Users who are viewing this thread

Back
Top Bottom