The OpenReport action was canceled

papic1972

Registered User.
Local time
Today, 18:16
Joined
Apr 14, 2004
Messages
122
Hi All,

I use the following code in the On No Data event of a report:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data exists for the date range entered.", vbInformation, "No Data Alert"
Cancel = True
End Sub

This works fine to cancel the opening of the report however Ms Access annoyingly then pop-ups another alert that reads as follows:

"The OpenReport action was cancelled". There is no error number.

I've tried putting in a DoCmd.Close after Cancel = True however this doesn't do the job.

Does anyone know of a way to prevent the Ms Access pop-up from appearing?

Many thanks!
 
Awesome stuff pbaldy, thanks heaps!
 
One more word on the subject: I have found that if the button to open the report calls an embedded macro to openreport rather than a vba routine, then I can do a macro in the report's On No Data event that executes a CancelEvent. Curiously, that does not trigger the unwanted message that the OpenReport action was canceled. I always follow that CancelEvent with a popup form announcing "No Data Available for this Report."
 
Its most likely a Printer issue. Access needs to have a working printer (and drivers) to work with even to Preview a report.

1) make sure there is a Default printer selected in *Windows*
2) In Access, File>Page Setup, make sure Access "knows" what printer to use.

I hope it Help
:rolleyes:
 
Welcome nayala. You realize this is a 4.5 year old thread?
 
Hi
I know that is Old, but i happened to me Yesterday and I did not see the solution.
So you mean that we have to do comments from Dec 2019 on?

Let me know any comments
 
No, there's no actual time limit. In this case the solution was provided in post 2 and acknowledged as such in post 3. Your post was basically a good solution to a different problem.
 

Users who are viewing this thread

Back
Top Bottom