×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can I use DoCmd.OutputTo acOutputReport to stop 2501 errors

Can I use DoCmd.OutputTo acOutputReport to stop 2501 errors

Can I use DoCmd.OutputTo acOutputReport to stop 2501 errors

(OP)
I use the following code to send a number of reports to my printer. There are about 16 reports in total, I have reduced the code just to keep things simple.

CODE

Private Sub CmdPrintFullNutriPlan_Click()
'Main Folder
'Soil Analysis Results for NutriPlan
DoCmd.OpenReport "rptSoilAnalRsltsForNutriPlan", acViewNormal
'N Max Field Limits (Report 1)
DoCmd.OpenReport "rptNMaxfieldlimits", acViewNormal
'N Max N From Manure Applications (Report 2)
DoCmd.OpenReport "rptCropNFromOMforNMaxCalcs", acViewNormal
'Fertiliser Requirement with Field Details
DoCmd.OpenReport "rptFertReqWithFieldDetail", acViewNormal
'Header
DoCmd.OpenReport "rptMainNPlanHeader", acViewNormal
DoEvents
MsgBox "Finished sending report to printer" 

I also use the following repeated code to send the same reports for PDF

CODE

'Header
DoCmd.OutputTo acOutputReport, "rptMainNPlanHeader", "PDF Format (*.pdf)", "" _
& "x:\Nutrifocus\NutriPlan Holding Folder\" & Me.[AccountNameLbl] + (Format(Now(), " ddmmyy")) + " - " & "1 - Header.pdf"
'NUTRIPLAN
DoCmd.OutputTo acOutputReport, "rpt10-NutriPlan09", "PDF Format (*.pdf)", "" _
& "x:\Nutrifocus\NutriPlan Holding Folder\" & Me.[AccountNameLbl] + (Format(Now(), " ddmmyy")) + " - " & "2 - NUTRIPLAN.pdf" 

Each report has the following code in NoData

CODE

Private Sub Report_NoData(Cancel As Integer)
     MsgBox "There are currently no records available for this report."
     Cancel = True
End Sub 

When I send the reports to the printer if there is no data then I get a message box click OK and then a run time error 2501 the openreport action was cancelled error message.

If I send the reports to PDF and there is no data I get the message box click OK but no run time error message.

What is the easiest way to stop the 2501 error messages? Can I use DoCmd.OutputTo acOutputReport to send the report to the printer and would this stop the 2501 error?

Or is there an easier way to send groups of reports to a printer?


I hope this all makes sense and thank you for any input.

RE: Can I use DoCmd.OutputTo acOutputReport to stop 2501 errors

You would need to add code in the CmdPrintFullNutriPlan_Click procedure to trap for err.number 2501. I expect you simply want the code to resume next if the error is encounter or maybe add a record to a log table.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close