PDF Toolbar Button

D

dan.cawthorne

Hello,

I was wondering if it is possible to create i button with in custom
toolbar I've made which which will enable me to PDF, Current open
reports.

ive manage to create i button which will do this from a list of
reports i have shown in a list box, and code is as follows,

Private Sub CmdPdf_Click()

Dim strDefaultPrinter As String

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("PDFCreator")

DoCmd.OpenReport [List0], acViewNormal

'Swtich back.'

Set Application.Printer = Application.Printers(strDefaultPrinter)

End Sub

So can this be done?
 
D

dan.cawthorne

Hello,

I was wondering if it is possible to create i button with in custom
toolbar I've made which which will enable me to PDF, Current open
reports.

ive manage to create i button which will do this from a list of
reports i have shown in a list box, and code is as follows,

Private Sub CmdPdf_Click()

Dim strDefaultPrinter As String

' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName

' switch to printer of your choice:

Set Application.Printer = Application.Printers("PDFCreator")

DoCmd.OpenReport [List0], acViewNormal

'Swtich back.'

Set Application.Printer = Application.Printers(strDefaultPrinter)

End Sub

So can this be done?

just like to let you know that I'm using Access 2003, ive looked down
the route of marcos and cant be done, and i cant seem to assign a on
click event to a custom button which is located on a tool bar,

also i think i could acheieve that im trying to do if i create a
single form with one button on it, which opens at same time as the
report,or i could open the form from the tool bar, and then have code
behind the command button, but if i could replace the following line
from above " DoCmd.OpenReport [List0], acViewNormal"
to something like "CurrentOpenReport, AcViewNormal"

is their any such code?
 
A

Arvin Meyer [MVP]

I've done it successfully that way, but I did use the actual name of the
default printer instead of .DeviceName
 
D

dan.cawthorne

I've done it successfully that way, but I did use the actual name of the
default printer instead of .DeviceName
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com


I was wondering if it is possible to create i button with in custom
toolbar I've made which which will enable me to PDF, Current open
reports.
ive manage to create i button which will do this from a list of
reports i have shown in a list box, and code is as follows,
Private Sub CmdPdf_Click()
Dim strDefaultPrinter As String
' get current default printer.
strDefaultPrinter = Application.Printer.DeviceName
' switch to printer of your choice:
Set Application.Printer = Application.Printers("PDFCreator")
DoCmd.OpenReport [List0], acViewNormal
'Swtich back.'
Set Application.Printer = Application.Printers(strDefaultPrinter)
So can this be done?

Thanks for the reply Arvin,

So how do i refer back to an current open report? Ive Created a form
"frmPdfButton" and they'll only ever be one report open at any one
time. I know i could create a frmPdfButton" form for every report, and
this would open with each report, but that just to long winded cause
i would have about 20No "frmPdfButtons" Forms?

Regards

Dan
 
A

Arvin Meyer [MVP]

So how do i refer back to an current open report? Ive Created a form
"frmPdfButton" and they'll only ever be one report open at any one
time. I know i could create a frmPdfButton" form for every report, and
this would open with each report, but that just to long winded cause
i would have about 20No "frmPdfButtons" Forms?

Add a listbox or combo box with all your reportnames. Then change the code
to something like:

DoCmd.OpenReport Me.lstReportNames, acNormal

to fill the list box, use code like:

Dim db As Database
Dim i As Integer
Dim contr As Container
Dim strRptList As String
Dim strRptName As String
Dim Length As Integer

Set db = CurrentDb
Set contr = db.Containers("Reports")

strRptList = ""
For i = 0 To contr.Documents.Count - 1
strRptName = contr.Documents(i).name
If strRptList <> "" Then strRptList = strRptList & "; "
Length = Len(strRptName)
strRptList = strRptList & strRptName
Next i

Me!lstRpt.RowSource = strRptList
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

OS dependant code 1
Error handler 3
runtime error 2212 3
PRINTER LIST ON WINDOWS 2003 NETWORK 1
Setting Default Printer 2
Difficulties with Microsoft example 1
Set Printer Problem 4
pdf in color 1

Top