Run time error 2501 openreport action was cancelled

D

Damon Heron

First let me start by saying I googled this question, which is probably a
common one, and tried everything without success.
When I open a report with no data from my form "frmAllReports" it goes to
the report open and cancels on no data. Fine so far. Then when it returns
I get the error msg. Here is my form code:
Public Sub cmdReports_Click()
On Error GoTo Err_cmdReports_Click
On Error Resume Next 'I added this on the advice of someone in newsgroup -
no help

DoCmd.OpenReport stDocName, acPreview 'stDocName is a public variable
that works fine unless no data

Exit_cmdReports_Click:
Exit Sub

Err_cmdReports_Click:
If Err.Number = 2501 Then Resume ExitHere
MsgBox "Error Number: " & Err.Number & vbCrLf & Err.Description
Resume ExitHere

End Sub

Nothing has changed with Access - it is on a single pc and the db is still
in development. Any ideas??
 
6

'69 Camaro

Hi, Damon.
Any ideas??

You don't have the ExitHere label defined, and you have several other
errors. Try:

Err_cmdReports_Click:
If Err.Number = 2501 Then GoTo ExitHere
MsgBox "Error Number: " & Err.Number & vbCrLf & Err.Description

ExitHere:
Err.Clear
End Sub


HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
Top