No Data Cancel Event

Snowman88

Registered User.
Local time
Yesterday, 21:20
Joined
Apr 4, 2007
Messages
26
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? :)
 
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 ..........
 
I am sorry, but I don't get what you are saying... i am a novice to access :(
 
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
 

Users who are viewing this thread

Back
Top Bottom