dbTalk Databases Forums  

Output report to RTF or PDF

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


Discuss Output report to RTF or PDF in the comp.databases.ms-access forum.



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

Default Output report to RTF or PDF - 01-08-2012 , 05:04 AM






Using Access 2010 I want to open a report in Print Preview, and at some
point, have the option of saving it as either an RTF or PDF

Have tried the code below in the OnOpen, OnClose and OnUnload event.

Private Sub Report_Unload(Cancel As Integer)

Dim OutFolder As String, OutFile As String

If If MsgBox("Do you want to save this report as a RTF file?", vbQuestion +
vbYesNo) = vbNo Then Exit Sub
End If

' Lookup the folder to store the report
OutFolder lder = Nz(Elookup("PDFPath", "QCoInfoPaths")) ' Find the correct
folder If OutFolder = "" Or Dir(OutFolder, vbDirectory) = "" Then ' No folder
MsgBox "The PDF Folder has not been defined", vbCritical
OpenFrm OpenFrm "CoInfo" ' Open form to set up folder path
Exit Sub
End If

OutFile = OutFolder & "\" & Me.Name & ".RTF"

DoCmd.OutputTo acReport, Me.Name, acFormatRTF, OutFile, True

End Sub

I always get the same error message on the OutputTo line.
Error r 2585 This action can't be carried out while processing a form or
report event. Am I correct in assuming then that the code has to be run from
something other than the report (say a command button on a form?

Thanks

Phil

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

Default Re: Output report to RTF or PDF - 01-08-2012 , 08:47 AM






"Phil" wrote in message news:jebt81$f8r$1 (AT) speranza (DOT) aioe.org...

Quote:
I always get the same error message on the OutputTo line.
Error r 2585 This action can't be carried out while processing a form or
report event. Am I correct in assuming then that the code has to be run
from
something other than the report (say a command button on a form?
You can launch the report and then launch a form. Or you can place the
options in a custom ribbon.

Not too much of a surprise that the report has already execcuted the un-load
event and is really quite much un-loaded.

Attempting to output a report that that already running a un-load event and
quite much turning out the "lights" so to speak is not going to work.

For all of my reports I built a custom ribbon. I have mail as PDF, save as
PDF, print to default printer, select printer to print to, export as word,
text, excel.

Just build this ribbon once, and you can use it for the next 10 years. In
fact I don't even remember the code or XML. Built this and then forget about
ever looking at how it works.

I had an example somewhere that used more of the built in PDF options, but I
cannot for some reason find that ribbon.

However, I do have a sample one here that uses some code and can be found
here:

http://www.kallal.ca/msaccess/DownLoad.htm

from above you want:
Access 2007 report ribbon example (with PDF and email).

The direct URL to the download form the above link resolves to this:
Access 2007 report ribbon example (with PDF and email).
http://www.kallal.ca/msaccess/RibbonReportPDF.zip


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

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

Default Re: Output report to RTF or PDF - 01-08-2012 , 09:22 AM



On 08/01/2012 14:47:36, "Albert D. Kallal" wrote:
Quote:
"Phil" wrote in message news:jebt81$f8r$1 (AT) speranza (DOT) aioe.org...

I always get the same error message on the OutputTo line.
Error r 2585 This action can't be carried out while processing a form
or
report event. Am I correct in assuming then that the code has to be run

from
something other than the report (say a command button on a form?

You can launch the report and then launch a form. Or you can place the
options in a custom ribbon.

Not too much of a surprise that the report has already execcuted the
un-load
event and is really quite much un-loaded.

Attempting to output a report that that already running a un-load event
and
quite much turning out the "lights" so to speak is not going to work.

For all of my reports I built a custom ribbon. I have mail as PDF, save
as
PDF, print to default printer, select printer to print to, export as
word,
text, excel.

Just build this ribbon once, and you can use it for the next 10 years.
In
fact I don't even remember the code or XML. Built this and then forget
about
ever looking at how it works.

I had an example somewhere that used more of the built in PDF options,
but I
cannot for some reason find that ribbon.

However, I do have a sample one here that uses some code and can be
found
here:

http://www.kallal.ca/msaccess/DownLoad.htm
from above you want:
Access 2007 report ribbon example (with PDF and email).

The direct URL to the download form the above link resolves to this:
Access 2007 report ribbon example (with PDF and email).
http://www.kallal.ca/msaccess/RibbonReportPDF.zip

Thanks Albert. That seems a very simple solution.

Must get to grips wit ribbons.

Phil

Reply With Quote
  #4  
Old   
PW
 
Posts: n/a

Default Re: Output report to RTF or PDF - 01-08-2012 , 11:56 AM



On Sun, 8 Jan 2012 15:22:46 GMT, "Phil" <phil (AT) stantonfamily (DOT) co.uk>
wrote:

Quote:
On 08/01/2012 14:47:36, "Albert D. Kallal" wrote:
"Phil" wrote in message news:jebt81$f8r$1 (AT) speranza (DOT) aioe.org...

I always get the same error message on the OutputTo line.
Error r 2585 This action can't be carried out while processing a form
or
report event. Am I correct in assuming then that the code has to be run

from
something other than the report (say a command button on a form?

You can launch the report and then launch a form. Or you can place the
options in a custom ribbon.

Not too much of a surprise that the report has already execcuted the
un-load
event and is really quite much un-loaded.

Attempting to output a report that that already running a un-load event
and
quite much turning out the "lights" so to speak is not going to work.

For all of my reports I built a custom ribbon. I have mail as PDF, save
as
PDF, print to default printer, select printer to print to, export as
word,
text, excel.

Just build this ribbon once, and you can use it for the next 10 years.
In
fact I don't even remember the code or XML. Built this and then forget
about
ever looking at how it works.

I had an example somewhere that used more of the built in PDF options,
but I
cannot for some reason find that ribbon.

However, I do have a sample one here that uses some code and can be
found
here:

http://www.kallal.ca/msaccess/DownLoad.htm
from above you want:
Access 2007 report ribbon example (with PDF and email).

The direct URL to the download form the above link resolves to this:
Access 2007 report ribbon example (with PDF and email).
http://www.kallal.ca/msaccess/RibbonReportPDF.zip


Thanks Albert. That seems a very simple solution.

Must get to grips wit ribbons.

Phil
If I can do it, you can too! :-)

-paulw

Reply With Quote
  #5  
Old   
(PeteCresswell)
 
Posts: n/a

Default Re: Output report to RTF or PDF - 01-08-2012 , 04:34 PM



Per Albert D. Kallal:
Quote:
For all of my reports I built a custom ribbon. I have mail as PDF, save as
PDF, print to default printer, select printer to print to, export as word,
text, excel.

Just build this ribbon once, and you can use it for the next 10 years. In
fact I don't even remember the code or XML. Built this and then forget about
ever looking at how it works.
I did the same thing, but used a subForm instead.

As Albert says, it's portable and durable - Although I wouldn't
mind plagiarizing Albert's ribbon bc my implementation is a
little clunky.
--
Pete Cresswell

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.