Output report to pdf - Please Help

  • Thread starter Thread starter Ian Baker
  • Start date Start date
I

Ian Baker

I have a client who wishes a report to be created for each record in a table
and saved as a pdf file in a specific folder with a specific file name. The
PC on which the app resides has Adobe Acrobat 5.0 and the printer driver is
called "Acrobat PDFWriter". Printing anything to that driver causes a prompt
for a path/filename (so I am told).

The problem I have is that I don't have a copy of this print driver to
develop and test in so:
1. How do I set the specific printer to the pdf driver for the report - any
suggestions other than buying the pdf print driver myself.
2. How do I actually output the report as a pdf to a specific location with
a specific file name. I have the following code to date:

Public Sub CreateRCTI(ComCalcDt As Date)
On Error GoTo HandleErr
Dim rstPrinciple As Recordset
Dim RCTIpath As String
Dim strFileName As String

'Get the path for the pdf folder from the paths table
RCTIpath = DLookup("RCTIPDFExportPath", "tlDatabasePath")

'Open a query to get only the principles that have been paid on the
passed date
Set rstPrinciple = CurrentDb.OpenRecordset("SELECT tblAccount.AccountNo,
etc etc etc

'Loop through each paid principle and create RCTI report as a pdf file
and save
'in the designated folder with a specific file name for each
Do While Not rstPrinciple.EOF

'Construct the path and file name for this principle
strFileName = RCTIpath & Format$(rstPrinciple!AccountNo, "000000") & _
"RCTI" & Format$(Date, "yyyy-mm-dd") & ".pdf"

'Now here is the problem how do I do it
' DoCmd.OpenReport "rptRCTI", acViewPreview, , "PrincAccount=" &
rstPrinciple!AccountNo


rstPrinciple.MoveNext
Loop

Any help is really appreciated
--
Regards

Ian Baker
Jackaroo Developments Pty Ltd
Download Jackaroo (an IT Help Desk application) at Web:
http://jackaroo.net.au
 
Dear Ian,

I encounte same problem,
First question is resolved,
but second trapped me.
1.PDF writer
You only need install any postscript printer driver in
your computer.
Then in desige of report, specify printer.
In postscript printer creats postscript file, it can been
converted into PDF by Adobe PDRwriter in customer computer.

2.Second question is print to file
I find it superising that VBA in word can set
parameter "Print to file" and file path & name but no VBA
function in access 2002 can employ it.

hence I am troubled with it.
Shoud you have any advise, please contact me on
(e-mail address removed)


-----Original Message-----
I have a client who wishes a report to be created for each record in a table
and saved as a pdf file in a specific folder with a specific file name. The
PC on which the app resides has Adobe Acrobat 5.0 and the printer driver is
called "Acrobat PDFWriter". Printing anything to that driver causes a prompt
for a path/filename (so I am told).

The problem I have is that I don't have a copy of this print driver to
develop and test in so:
1. How do I set the specific printer to the pdf driver for the report - any
suggestions other than buying the pdf print driver myself.
2. How do I actually output the report as a pdf to a specific location with
a specific file name. I have the following code to date:

Public Sub CreateRCTI(ComCalcDt As Date)
On Error GoTo HandleErr
Dim rstPrinciple As Recordset
Dim RCTIpath As String
Dim strFileName As String

'Get the path for the pdf folder from the paths table
RCTIpath = DLookup
("RCTIPDFExportPath", "tlDatabasePath")
'Open a query to get only the principles that have been paid on the
passed date
Set rstPrinciple = CurrentDb.OpenRecordset("SELECT tblAccount.AccountNo,
etc etc etc

'Loop through each paid principle and create RCTI report as a pdf file
and save
'in the designated folder with a specific file name for each
Do While Not rstPrinciple.EOF

'Construct the path and file name for this principle
strFileName = RCTIpath & Format$(rstPrinciple! AccountNo, "000000") & _
"RCTI" & Format$(Date, "yyyy-mm-dd") & ".pdf"

'Now here is the problem how do I do it
' DoCmd.OpenReport "rptRCTI",
acViewPreview, , "PrincAccount=" &
 
Ian:

Take a look at our PDF and Mail Library for Access. You'll find it on our
web. It will allow you to do exactly what you are trying to do, i.e. output
a pdf file and auto name the resulting file. You can loop through your
recordset to output a pdf file per Account as noted in your post.
 
Michael:

Stop by our web and look in our Developer Tools area for our PDF and Mail
Library. It will allow you to output a PDF file from an Access report with
as little code as:

Dim objPDF as PDFClass
Const PDF_ENGINE_PDFWRITER = 1

Set objPDF = New PDFClass
With objPDF
.ReportName = "YourReport"
.PDFEngine = PDF_ENGINE_PDFWRITER
.OutputFile = "C:\somedir\somefile.pdf
.PrintImage
End With

Set objPDF = Nothing
 
Back
Top