CancelEvent

M

Mike

I am calling a report by clicking on a date on the calendar control. When
there is no data to print, the NoData event is supposed to kick in and stop
the printing, then pop up a message box. I am using the code below to do it.

Private Sub Report_NoData(Cancel As Integer)
DoCmd.CancelEvent
Call Msg("AllDept")
End Sub

However, the printing does not cancel. The custom mesage box pops up on the
screen but is immediately overwritten by a window that says Error 2501 - The
OpenReport Action was cancelled. Then it prints a blank page to the printer.

How can I make sure the custom message comes up, the printing is cancelled
and the MS message box does not appear? Is it because i am calling it from
the calendar control? When I run the report by itself by just clicking on it
and entering a date in the parameters box, everything works fine. The report
gets cancelled and my message box comes up on the screen. No MS message
appears. Is there another way to cancel the report instead of cancelevent?

Thanks!
MAB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top