Error opening report - OpenReport action was cancelled

  • Thread starter Thread starter Vic
  • Start date Start date
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
 
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.
 
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.
 
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
 
Back
Top