Cannot avoid Warning on NoData

DavidWRouse

Registered User.
Local time
Today, 03:00
Joined
Jul 24, 2003
Messages
42
I cannot get rid of a Warning box saying "The OpenReport was action was cancelled", I dont want this message.
Follwing is my routine..

Private Sub Report_NoData(Cancel As Integer)
On Error GoTo Err_Report_NoData

DoCmd.SetWarnings (WarningsOff)
Cancel = True
DoCmd.SetWarnings (WarningsOn)

Exit_Report_NoData:
Exit Sub

Err_Report_NoData:
MsgBox Err.Description, , "APPLICATIONS"
Resume Exit_Report_NoData

End Sub
 
Also posted under Modules. One posting will suffice.
 
The following is from the setwarnings help screen:

"You can use this action to prevent modal warnings and message boxes from stopping the macro. However, error messages are always displayed."

Use the err to find the error code then use error trapping similiar to this example(the 53 may not be your code).

Err_Report_NoData:
If err = 53 then
Resume next 'or some other part of resume)
End if
MsgBox Err.Description, , "APPLICATIONS"
Resume Exit_Report_NoData

This way it traps the error, doesn't give an error message and resumes the code.
 
As I recall the error is caused by the calling form having not completed it's action NOT the OnNoData event, you need error trapping in your button for error(hint: use Msgbox Err.Number to establish the error number to catch). I think it's either 2501 or 2051, I never remember. :)
 
Thanks guys has given me something to think about. Wiil be looking into it
 
Wow its all ok now

Thanks guys again, Just been and tidied up my various routines. But error trapping in a routine that did not have any and it has fixed it. Not sure exactly why it works but the code looks neat and logical.
It also fixed another bug that I was about to post. You both really helped. I am very new to Error trapping code, and still got alot to learn. Will be getting a good book soon.

All is working and i can now get on with my work.
 

Users who are viewing this thread

Back
Top Bottom