Full Version: print button, option to select printer
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
rdspollin
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_Workscope_Review_Report_test___PRIN:
Exit Sub

Err_Workscope_Review_Report_test___PRINT_Click:
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?
stimpo
DoCmd.RunCommand acCmdPrint
rdspollin
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
kuifjexx
Check this MS KB Article => How to automate the process of selecting the printer for a report in Microsoft Access

HTH

Greetz from Belgium compute.gif

Luc aka Kuifjexx
stimpo
you should have something like this.

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

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.
rdspollin
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
kuifjexx
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.