Error opening report - OpenReport action was cancelled

V

Vic

I have an Access database for 8 users. Only one user is
having trouble opening a report and the other users are
not. I'm using a command button to execute the report
and the error is "Run-time error '2501'; The OpenReport
action was canceled.". My code is below and I'm using
Access 2003. Please help, I've spent a lot of time
trying to figure this out and I can't. I don't
understand why he gets the error and the rest of the
users do not.


Private Sub cmdPRReport_Click()
On Error GoTo Err_cmdPRReport_Click

Dim stDocName As String

stDocName = "PR REPORT"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdPRReport_Click:
Exit Sub

Err_cmdPRReport_Click:
MsgBox Err.Description
Resume Exit_cmdPRReport_Click

End Sub
 
P

PC Datasheet

Do you open a form for data input such as start and end dates in the report
OnOpen event. If you do and the user cancels or closes that form he will get the
error message you mention.
 
G

Guest

The form is for data input, but there is no code for the
report or for OnOpen event. I tried to close the
application, open it again, go straight to the form with
out modifying any data open the report and still get the
error. I even uninstall and reinstall office on the
computer and still get the error.
 
F

Fredg

Vic,
Add some error handling to your code to trap the
common error (Noted with ' ***** below):

Private Sub cmdPRReport_Click()
On Error GoTo Err_cmdPRReport_Click

Dim stDocName As String

stDocName = "PR REPORT"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdPRReport_Click:
Exit Sub

Err_cmdPRReport_Click:
If Err = 2501 Then ' ******
Else ' ******
MsgBox Err.Description
End If ' ******
Resume Exit_cmdPRReport_Click

End Sub
 

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