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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2501 1

Status
Not open for further replies.

sdollen

Technical User
Oct 12, 2002
24
US
I am building a switchboard and have a button for the users to click to generate a report. Once the button is clicked, it gives the user the ability to enter a query parameter. However, if the "cancel" button is clicked on the parameter box, I recieve the "Run-time error 2501" "The OpenReport action was canceled." error message.

I am using some simplistic code tied to the button -

Private Sub Command3_Click()
DoCmd.OpenReport "rptContactsByMember", acPreview
End Sub

I must be missing something here! I'd just like the parameter box to close without generating the error or a blank report.

Thanks everyone for your help.

 
Fast fix:

Private Sub Command3_Click()
On Error Resume Next
DoCmd.OpenReport "rptContactsByMember", acPreview
End Sub

Thorough fix (you can customize it for any error that may occur):

Private Sub Command3_Click()
On Error goTo ErrHandler
DoCmd.OpenReport "rptContactsByMember", acPreview

Finish:
Exit Sub
ErrHandler:
Select Case Err.Number
Case 2501
Resume Finish
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume Finish
End Select
End Sub

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
This is what helped me:

ref: building/previewing/printing reports in Access 2003

Apparently, report related functinality (building/previewing/printing) in MS Access DBMS is directly effected by the way printing is set up on users PC. Printer that is set up as a default and its driver(s) may cause Access reporting to break!

It has been noticed that combination of MS Windows XP Professional OS, Office 2003 (Access 2003), and HP LaserJet 5/5M printer was causinf break down of reporting. In Windows 2000 Professional environment with the same Office and Printer versions/models/setups reporting was stable and functining properly.

While in the process of installing new driver(s) for HP LaserJet 5/5M printer trivial manipulation with default printers was suggested and "fixed" user with report accessing.
HP LaserJet 4100 PCL 6 network printer was installed on user box and set up as adefault.
After previewing the report in Access user was able to Print the report to the original printer
(in pPrint dialog select another - not default - printer).

We expect the problem to be fixed permanntly after installing appropriate/new driver(s) for
HP LaserJet 5/5M printer on user PC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top