Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2501

Status
Not open for further replies.

deadfish

Programmer
Nov 13, 2002
50
0
0
HK
Hi,

I have scheduled a Access 2003 report to be printed every morning (using Windows schedule task), on a Windows 2003 server. It has been work fine for few months but I got the "Error 2501 The OpenReport action was canceled" yesterday. I use

DoCmd.OpenReport "RptA", acViewNormal, "", "", acHidden

to print the report. After that error, I reboot the server, print the report directly in Access and everything works fine again...

How to get rid of this error? Thanks a lot.
 
Without knowing your set-up, or complete code,
I can't assume what's causing the error?

But, as a work-around masybe use some error handling,
to exit a bit more gracefully?

On Error GoTo xxx

DoCmd.OpenReport "RptA", acViewNormal, , , acHidden

xx:
Exit Sub
xxx:
If err = 2501 Then
Resume Next
Else
MsgBox err & vbcrLf & Error$
Resume xx
End If

End sub



 
My code is like this:

Function printrpt()
DoCmd.OpenReport "RptA", acViewNormal, "", ""
Application.Quit
End Function

I would like to schedule this module to be executed every morning. After printing the report, it close the Access also. Because the code works fine for first months, I just don't know if my code has cause the problem.

If I use the code

If err = 2501 Then
Resume Next

would the report be printed out if the error 2501 occurs again?

Thanks in advance!
 
Sorry, I still don't know why your code fails but,
will the report print using "resume Next"? NO!

it will continue to the next line of code,
in this case Quit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top