dbTalk Databases Forums  

OutputTo PDF error

comp.databases.ms-access comp.databases.ms-access


Discuss OutputTo PDF error in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
septimus
 
Posts: n/a

Default OutputTo PDF error - 06-08-2011 , 10:23 PM






I have a procedure that is intended to publish an Access report as a
PDF repeatedly, each time with the recordsource data changed.

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

Trouble is, when I run the same line of code in the middle of a loop,
I get the following error:
"Run-Time error 2501: The OutputTo action was canceled"

It doesn't appear to be a problem with the report, it works fine when
I open it under the same conditions.

I can post at least some of the code if anyone thinks it would help,
but I won't do so now because it's lengthy.

Anybody encountered this problem? Solutions?

Thanks.

Reply With Quote
  #2  
Old   
John Spencer
 
Posts: n/a

Default Re: OutputTo PDF error - 06-09-2011 , 08:15 AM






Have you tried adding a DoEvents and some delay in the loop?

While Not .EOF
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath
DoEvents
sSleep 2000 'Sleep for two seconds
Wend

You can find the code for sSleep sub at
http://www.mvps.org/access/api/api0021.htm

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

On 6/8/2011 11:23 PM, septimus wrote:
Quote:
I have a procedure that is intended to publish an Access report as a
PDF repeatedly, each time with the recordsource data changed.

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

Trouble is, when I run the same line of code in the middle of a loop,
I get the following error:
"Run-Time error 2501: The OutputTo action was canceled"

It doesn't appear to be a problem with the report, it works fine when
I open it under the same conditions.

I can post at least some of the code if anyone thinks it would help,
but I won't do so now because it's lengthy.

Anybody encountered this problem? Solutions?

Thanks.



Reply With Quote
  #3  
Old   
septimus
 
Posts: n/a

Default Re: OutputTo PDF error - 06-09-2011 , 10:36 AM



That doesn't seem to help because the error message comes up before
the program has a chance to move on to the "DoEvents" command.

It says "Now Outputting 'rptIAR' to the file '[path].pdf'" and goes
through all pages of the report and then I get this "action canceled"
error.

Other ideas?

On Jun 9, 8:15*am, John Spencer <JSPEN... (AT) Hilltop (DOT) umbc> wrote:
Quote:
Have you tried adding a DoEvents and some delay in the loop?

While Not .EOF
* *DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath
* *DoEvents
* *sSleep *2000 'Sleep for two seconds
Wend

You can find the code for sSleep sub at
* *http://www.mvps.org/access/api/api0021.htm

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

On 6/8/2011 11:23 PM, septimus wrote:







I have a procedure that is intended to publish an Access report as a
PDF repeatedly, each time with the recordsource data changed.

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

Trouble is, when I run the same line of code in the middle of a loop,
I get the following error:
"Run-Time error 2501: The OutputTo action was canceled"

It doesn't appear to be a problem with the report, it works fine when
I open it under the same conditions.

I can post at least some of the code if anyone thinks it would help,
but I won't do so now because it's lengthy.

Anybody encountered this problem? Solutions?

Thanks.

Reply With Quote
  #4  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: OutputTo PDF error - 06-10-2011 , 06:21 PM



"septimus" wrote in message
news:49a1b4ae-a663-48a4-a9c2-1e482bc800b2 (AT) hd10g2000vbb (DOT) googlegroups.com....

Quote:
When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath
The above leaves the report open. Place a command to close the report, like
this:


DoCmd.Close acReport,"rptIAR"
DoEvents


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kallal (AT) msn (DOT) com

Reply With Quote
  #5  
Old   
septimus
 
Posts: n/a

Default Re: OutputTo PDF error - 06-10-2011 , 08:36 PM



On Jun 10, 6:21*pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal... (AT) msn (DOT) com>
wrote:
Quote:
"septimus" *wrote in message

news:49a1b4ae-a663-48a4-a9c2-1e482bc800b2 (AT) hd10g2000vbb (DOT) googlegroups.com....

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

The above leaves the report open. Place a command to close the report, like
this:

DoCmd.Close acReport,"rptIAR"
DoEvents

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kal... (AT) msn (DOT) com
No, sorry, I think the way I phrased that was misleading. The report
never opens, so I can't close it using "DoCmd.Close". The first time
the code loop gets to the OutputTo command it says "Now Outputting
'rptIAR' to the file '[path].pdf'" and goes through all pages of the
report before I get the "action canceled" error.

What I meant when I said "When I use the following line of code to
publish the report to PDF a single time it works" is that if I place
that line of code (the OutputTo command) in a different procedure with
no loop, it works.

But in this context, it doesn't even matter what report I'm
outputting, I still get the "cancel" error. Why does Access think I'm
canceling the output?? Here's the code in case it helps:

'Start looping through records.
Do While Not rstGrouping.EOF

'Populate the recordsource of the report.
PopulateAnswerCounts "Interim", rstGrouping

'Build the path and file name of the PDF we're producing.
strPath = BuildFilePath("Interim", Me)

'Publish the report in PDF format.
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath,
False

rstGrouping.MoveNext
Loop

Reply With Quote
  #6  
Old   
septimus
 
Posts: n/a

Default Re: OutputTo PDF error - 06-10-2011 , 09:25 PM



On Jun 10, 8:36*pm, septimus <ovengra... (AT) yahoo (DOT) com> wrote:
Quote:
On Jun 10, 6:21*pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal... (AT) msn (DOT) com
wrote:









"septimus" *wrote in message

news:49a1b4ae-a663-48a4-a9c2-1e482bc800b2 (AT) hd10g2000vbb (DOT) googlegroups.com....

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

The above leaves the report open. Place a command to close the report, like
this:

DoCmd.Close acReport,"rptIAR"
DoEvents

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kal... (AT) msn (DOT) com

No, sorry, I think the way I phrased that was misleading. The report
never opens, so I can't close it using "DoCmd.Close". The first time
the code loop gets to the OutputTo command it says "Now Outputting
'rptIAR' to the file '[path].pdf'" and goes through all pages of the
report before I get the "action canceled" error.

What I meant when I said "When I use the following line of code to
publish the report to PDF a single time it works" is that if I place
that line of code (the OutputTo command) in a different procedure with
no loop, it works.

But in this context, it doesn't even matter what report I'm
outputting, I still get the "cancel" error. Why does Access think I'm
canceling the output?? Here's the code in case it helps:

* * 'Start looping through records.
* * Do While Not rstGrouping.EOF

* * * * 'Populate the recordsource of the report.
* * * * PopulateAnswerCounts "Interim", rstGrouping

* * * * 'Build the path and file name of the PDF we're producing.
* * * * strPath = BuildFilePath("Interim", Me)

* * * * 'Publish the report in PDF format.
* * * * DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath,
False

* * * * rstGrouping.MoveNext
* * Loop
Found the problem. Turned out to be just an invalid character in the
file name. Thanks for your assistance.

Reply With Quote
  #7  
Old   
Tony Toews
 
Posts: n/a

Default Re: OutputTo PDF error - 06-12-2011 , 04:03 PM



On Fri, 10 Jun 2011 19:25:07 -0700 (PDT), septimus
<ovengravel (AT) yahoo (DOT) com> wrote:

Quote:
Found the problem. Turned out to be just an invalid character in the
file name.
Oh, now that's interesting. Thanks for posting the problem.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/

Reply With Quote
  #8  
Old   
grovelli
 
Posts: n/a

Default Re: OutputTo PDF error - 06-13-2011 , 07:48 AM



On 11 Giu, 03:25, septimus <ovengra... (AT) yahoo (DOT) com> wrote:
Quote:
On Jun 10, 8:36*pm, septimus <ovengra... (AT) yahoo (DOT) com> wrote:





On Jun 10, 6:21*pm, "Albert D. Kallal" <PleaseNOOOsPAMmkal... (AT) msn (DOT) com
wrote:

"septimus" *wrote in message

news:49a1b4ae-a663-48a4-a9c2-1e482bc800b2 (AT) hd10g2000vbb (DOT) googlegroups.com...

When I use the following line of code to publish the report to PDF a
single time, it works:
DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath

The above leaves the report open. Place a command to close the report, like
this:

DoCmd.Close acReport,"rptIAR"
DoEvents

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kal... (AT) msn (DOT) com

No, sorry, I think the way I phrased that was misleading. The report
never opens, so I can't close it using "DoCmd.Close". The first time
the code loop gets to the OutputTo command it says "Now Outputting
'rptIAR' to the file '[path].pdf'" and goes through all pages of the
report before I get the "action canceled" error.

What I meant when I said "When I use the following line of code to
publish the report to PDF a single time it works" is that if I place
that line of code (the OutputTo command) in a different procedure with
no loop, it works.

But in this context, it doesn't even matter what report I'm
outputting, I still get the "cancel" error. Why does Access think I'm
canceling the output?? Here's the code in case it helps:

* * 'Start looping through records.
* * Do While Not rstGrouping.EOF

* * * * 'Populate the recordsource of the report.
* * * * PopulateAnswerCounts "Interim", rstGrouping

* * * * 'Build the path and file name of the PDF we're producing.
* * * * strPath = BuildFilePath("Interim", Me)

* * * * 'Publish the report in PDF format.
* * * * DoCmd.OutputTo acOutputReport, "rptIAR", acFormatPDF, strPath,
False

* * * * rstGrouping.MoveNext
* * Loop

Found the problem. Turned out to be just an invalid character in the
file name. Thanks for your assistance.- Nascondi testo citato

- Mostra testo citato -
What's the code for PopulateAnswerCounts and BuildFilePath?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.