I discovered what was causing the problem. The reports either had bad
invisible code in them from Access 97, or they weren't converted properly
into Access 2007. Looking closely at the pages that were causing the error
2501 (and on the computers that were giving the error 2501), I noticed that
the reports had become about 25 inches in height! They were supposed to be
standard 8-1/2 by 11 inches. Access wouldn't allow me to change it back to
the proper height. I tried dragging the bottom of the page to the correct
height, but it wouldn't budge. I tried entering the correct height in
properties, but it would immediately revert back to 25 inches.
Cause: What was happening was since the reports were defective, they
couldn't be sent to the printer without an error. Too big for the printer, I
suppose. The printer is a standard 8-1/2 by 11 printer. The error that was
being generated by being rejected by the printer was error 2501. Error 2501
is the error number that is generated when the user clicks cancel when
reports are being sent to the printer.
Solution: Create a new report, copy-and-paste portions of the original
report into the new report. DON'T copy-and-paste the entire original report
into the new report, it will copy the 'bad' stuff that causes the error into
the new report. Copy-and-paste the header, then the body, then the footers,
etc. Don't forget to copy-and-paste the VBA code behind, and the properties
including the data source.
Hope this helps. Microsoft didn't have a solution, but I made my own.
Another thing. I set up a fake printer on the 'test' computer. That way when
testing code that was to send several reports to the printer, I wouldn't have
to waste paper. The fake printer I set up was a black and white printer. When
I put Access on production computers that were to print some of these reports
in color, they would only print in black and white. I had a heck of a time
finding out how to change the reports to print in color. I suspect that if I
had installed a color fake printer to begin with, the reports might print in
color on the production computers without further modification.
"John Price" wrote:
> I am getting a similar error for the same situation.
>
> In my case the report is fairly complex and has sub-reports.
> I am attempting to output to PDF.
>
>
> "Spacy Mike" wrote:
>
> > When I run an Access 2007 vba that prints several reports to a printer or
> > outPutTo a PDF or or both, I get error 2501 with using the 4th, or so either
> > outPutTo or PrintTo. The first few outPutTo or PrintTo work, then I get this
> > error. At the same point. Cancel is never clicked, the pc is left alone while
> > vba is running. All search & help says somebody clicked cancel while
> > outputing or printing, but that is not the case. I don't care about error
> > catching, because that still not create the printouts of PDF's.
> >
> > This only happens on one pc. The other pc (where I mostly designed the
> > Access code) works perfectly.
> >
> > Here are a few lines of the code:
> > =============
> > 'PC Report
> > If Forms![Print all Reports for this Job]![ckPrintPCB] Then
> > DoCmd.OpenReport (Me.PcReportName), acViewReport, , , ,
> > NullToString(Me.ReportDate)
> > If mPrint Then DoCmd.PrintOut acPrintAll
> > If mPDF Then DoCmd.OutputTo acOutputReport, Me.PcReportName,
> > acFormatPDF, mReportsPath & "\PC Supplement.PDF"
> > DoCmd.Close acReport, Me.PcReportName ', acSaveNo
> > End If
> >
> > 'Metals Report
> > If Forms![Print all Reports for this Job]![ckPrintMetals] Then
> > DoCmd.OpenReport (Me.MetalsReportName), acViewReport, , , ,
> > NullToString(Me.ReportDate)
> > If mPrint Then DoCmd.PrintOut acPrintAll
> > If mPDF Then DoCmd.OutputTo acOutputReport, Me.MetalsReportName,
> > acFormatPDF, mReportsPath & "\Metals Supplement.PDF"
> > DoCmd.Close acReport, Me.MetalsReportName ', acSaveNo
> > End If
> >
> > ===================
> > The first few reports work prior to the above code, as does the PC report
> > (as the above code). Then when it attempts the Metals report, it errors 2501
> > everytime on this one particular PC.
> >
> > I tried commenting out some of the code, and let it do the outPutTo only,
> > same result. On the pc where this Access works without errors, it can handle
> > several outputTo & PrintTo's at a time.
> >
> > Both PC's have Office 2007 trial version. They also have Office 97. I am
> > trying to get Access 97 converted to 2007 before we upgrade all the pc's with
> > 2007. I accidentally installed Access 2007 runtime after the Office 2007
> > installation. I remove Office 2007 and reinstalled from scratch, and ran
> > updates, to see if that would fix the problem, but it didn't.
> >