View Full Version : Print from button


a.sinatra
01-31-2004, 03:31 PM
Here's what i want:

Button on a form named "cmdPrint"
When clicked: print a report named "rptRiderSetupAvg" ( i want the dialog for the printer to appear, i dont want the report to open )

Oldsoftboss
01-31-2004, 11:56 PM
Something I've had stored away which will do what you want.....

Print dialogue box

To show the Print dialogue box to allow you to select the printer you wish to print to do the following:


Set the code on the command button to docmd.openreport “ReportName”,acviewprintpreview


Add the following to the "On Activate" event of the report.

Private Sub Report_Activate()
On Error GoTo Err_Report_Activate

If Me.Report.HasData Then
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Me.Name

Else
MsgBox "There is no data for this report. Canceling report...", vbInformation, " No Data"
DoCmd.Close acReport, Me.Name

End If

Err_Report_Activate:
Resume Next
DoCmd.Close acReport, Me.Name

End sub

.................................................. ...............................................

HTH

Dave

DAW
12-20-2006, 07:15 AM
All,
This solution certainly helps my case, but I will be printing many documents (up to 100) from a report to pdf, so obviously don't want the dialog opening every time. I need to set the printer to pdf then let the loop run.
Any ideas anyone?

Oldsoftboss
12-20-2006, 09:00 PM
There is a post somewhere here which changes the default printer to your selection (PDF I suppose), prints, then changes the default printer back to the original.

Dave