Full Version: print button, option to select printer
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
i have the following code for my print button:

Private Sub Workscope_Review_Report_test___PRINT_Click()
On Error GoTo Err_Workscope_Review_Report_test___PRINT_Click

Dim stDocName As String

stDocName = "Rpt: Cycle 0 Form"
DoCmd.OpenReport stDocName, acNormal

Exit Sub

MsgBox Err.Description
Resume Exit_Workscope_Review_Report_test___PRIN

End Sub

this is good but does not give me an option to select which printer i would like to send to. how to i make the print dialog box appear when this button is pressed?
DoCmd.RunCommand acCmdPrint
thanks for the reply. i like the avatar/profile pic. smoke me a kipper i'll be back for breakfast wink.gif

whereabouts do i put the 'DoCmd.RunCommand acCmdPrint' code?

i tried adding it after 'DoCmd.OpenReport stDocName, acNormal' but this still prints to my default printer before promoting me to print again

i tried replacing 'DoCmd.OpenReport stDocName, acNormal' with 'DoCmd.RunCommand acCmdPrint' but that just prints my form not the report
Check this MS KB Article => How to automate the process of selecting the printer for a report in Microsoft Access


Greetz from Belgium compute.gif

Luc aka Kuifjexx
you should have something like this.

docmd.openreport "report name", acviewpreview
docmd.runcommand accmdprint

That will open your report in preview mode, show the print dialog box and then close the report when you either print or cancel the print dialog box.
kuifjexx, thanks for the link, looks useful!

stimpo, works perfectly, removed the last line 'docmd.close' so the report doesnt close after print or cancel

thanks for the help frown.gif
Glad we could help you

Greetz from Belgium compute.gif

Luc aka Kuifjexx
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.