Print 2 copies of a report

casey

Registered User.
Local time
Today, 02:55
Joined
Dec 5, 2000
Messages
448
I have a button to print a report. Can I set it up to print multiple copies of the same report? I've looked in the help, but can't find the answer. Any ideas? Thanks.
 
Casey

You could show the print dialog box -

Make Print Dialog Box appear when printing a Report

Add the following to the "On Activate" event of the report. This will cause the Print Dialog Box to open so you can choose a printer, and also choose the number of copies .... ect.

After you make the choices in the Printer Dialog Box the report will print ... but the code will close the report without it ever appearing on screen.

There is also code here in case the result of the recordset returns "no records" so there's no need to use the On No Data event. It will display a message box that you can alter to fit your needs.

Code:
'---------------Code Start-----------------------

Private Sub Report_Activate()
On Error GoTo Err_Report_Activate

Dim strMsg As String
Dim strTitle As String

strMsg = "There Were No Records Returned." & vbCrLf & "Print has been Cancelled."
strTitle = " No Records Returned"
 
If Me.Report.HasData Then
  DoCmd.RunCommand acCmdPrint
  DoCmd.Close acReport, Me.Name
Else
  MsgBox strMsg, vbInformation + vbOKOnly, strTitle
  DoCmd.Close acReport, Me.Name
End If
 
Err_Report_Activate:
  Resume Next
  DoCmd.Close acReport, Me.Name
 
End Sub

'---------------Code End-------------------------

HTH

Graham
 
Thanks for your suggestion Graham...

But I was hoping to get by w/o displaying the dialog box. I wanted to print directly from the form's button. Is this possible?
 
Try this:

Code:
Dim NumCopies as Integer
NumCopies = 3
  DoCmd.OpenReport "ReportName", acViewPreview  
  DoCmd.PrintOut acPrintAll, , , , NumCopies
  DoCmd.Close acReport, "ReportName"

This should cause it to print 3 copies. You set the variable NumCopies before you begin.
 
Yes,

That's what I need. The code is almost exactly what I had. However, when I tried this it printed the current form that called the procedure. I guess I'm unclear on what causes this to print the report I'm trying to refer to in the first part of the code.
 
I'm not sure what's causing the problem, as I'm using this code pretty much as-is, but you could add the SelectObject as below:
Code:
Dim NumCopies as Integer
NumCopies = 3

DoCmd.OpenReport "ReportName", acViewPreview
DoCmd.SelectObject acReport,"ReportName"
DoCmd.PrintOut acPrintAll, , , , NumCopies
DoCmd.Close acReport, "ReportName"

Hope this helps.
 
ListO

Thanks for helping me figure this out! I think I had the option acPrintAll set. Once removed, it worked great! Just wanted to thank you.


Casey
 
Cool

This source is cool!!

Thanks.

I have used this to give my users the benefit of the Printer dialog box without actually opening the report!.

This works wonders for me.


Edwin
 

Users who are viewing this thread

Back
Top Bottom