View Full Version : No Data Cancel Event


Snowman88
04-17-2007, 04:36 AM
Hi again :)

I am stuck again..... I have a form where I can generate different reports with different variables.

What will be quite common is that the there will be no report with the given variables. I did the "on no data" event with a msgbox and "docmd.cancelevent". It works fine but access gives me an error message which says:

Run time error 2501

The OpenReport action was canceled.


Which is exactly was is supposed to happen....how do I get rid of that error message? :)

Dennisk
04-17-2007, 04:43 AM
use the on error goto
in the event that opens the report
and trap that number.

what I do is to create a module that contains Constants
basConstants
create your Constant

Public Const NO_DATA = 2501

then in the error trapping code

if Err <> NO_DATA THEN ..........

Snowman88
04-17-2007, 04:47 AM
I am sorry, but I don't get what you are saying... i am a novice to access :(

Dennisk
04-17-2007, 05:37 AM
If you used the wizard to create a button to print your report then it will already contain error trapping. This will consists of two lines

msgbox err.description
resume Exit_NameOfButton_Click

replace this with
if err <> NO_DATA then
msgbox err.description
endif
resume Exit_Name_OfButton_Click

to create your module click on the module tab of the database window and click new then enter the constant