Print Button Code

M

Meaty

Hi, I am using the following code to print a report.
Please suggest code to show the Print Dialog Box before the report prints so
I can change the printer.
Also would like another button to produce a PDF using "PDFCreator" which is
one of the printers in the dialog box.


Private Sub PQ_Click()
On Error GoTo Err_PQ_Click

Dim stDocName As String

stDocName = "Quote"
DoCmd.OpenReport stDocName, acNormal, "Quote Filter"

Exit_PQ_Click:
Exit Sub

Err_PQ_Click:
MsgBox Err.Description
Resume Exit_PQ_Click

End Sub
 
A

Allen Browne

Open the report in preview, and then open the printer dialog:
DoCmd.OpenReport stDocName, acViewPreview, "Quote Filter"
RunCommand acCmdPrint

(Actually, I'm not sure how good the Filter argument is: I've always found a
WhereCondition better.)

If this is Access 2002 or later, you can set the Printer before you
openreport:
Set Printer = Printers("xxxx")
where xxxx is the name of the PDFCreator printer.
Then to reset to the default printer:
Set Printer = Nothing
 
J

J_Goddard via AccessMonster.com

Hi -

One way is to change scNormal to acPreview on the docmd.openreport line.
That will put the report on the screen, from which you can use File - Print
and select a printer.

John
 

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

Top