I found an old thread that might help you....
Printing more than one copy of a reportAll 3 messages in topic - view as
tree
Steve Arbaugh
Jun 21 2002, 12:10 pm show options
Newsgroups: microsoft.public.access.reports
From: "Steve Arbaugh" <
[email protected]> - Find
messages by this author
Date: Fri, 21 Jun 2002 14:07:32 -0400
Local: Fri, Jun 21 2002 12:07 pm
Subject: Re: Printing more than one copy of a report
Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse
When you say print report button, I assume that this is a button on a
form.
Here's one way to do that; if you'd like to give your user's the
ability to
select a printer at the same time you might stop by our web site and
look at
our "On the Fly Printing" code which you can drop into your database
and
have your solution in about 5 minutes.
But to print a couple of copy of a report from a button on a form use
code
like that below by signature.
HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
--------------begin code-------------------
Sub MyButton_Click ()
On Error Resume Next
DoCmd.Echo False 'Turn off screen painting
Docmd.SelectObject acReport, "MyReportName", True
Docmd.PrintOut acPrintAll, , , , 2 'Print two copies
Me.SetFocus 'return focus to the form
Docmd.Echo True 'Turn on Screen painting
End Sub
- Hide quoted text -
- Show quoted text -
I require help with code to print two copies of a report
when the print report button is selected. I am assuming
the only way to do this is with VB code, but I am at a
loss as to how to go about it.
Any help is appreciated.
Thank you.
Cathy
Jun 21 2002, 1:43 pm show options
Newsgroups: microsoft.public.access.reports
From: "Cathy" <
[email protected]> - Find messages by
this author
Date: Fri, 21 Jun 2002 12:40:04 -0700
Local: Fri, Jun 21 2002 1:40 pm
Subject: Re: Printing more than one copy of a report-HELP!
Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse
Thanks for the code Steve!
I tried it and it worked fine. Unfortunately, however, I
already have the following code for the Click event of
that button to print the current record, rather than all
records.
I take it you cannot have both actions happening in the
event because it ignored the first action and performed
the second resulting in all the forms being printed on the
report instead of the current one, but 2 copies were being
printed.
The code for the Click event is layed out like this:
Private Sub PrintPO_Click()
On Error GoTo Err_PrintPO_Click
Dim stDocName As String
Dim strWhereCondition As String
strWhereCondition = "PONumberID = " & Me!PONumberID
stDocName = "PO Fax Report"
DoCmd.OpenReport stDocName, acViewNormal, _
WhereCondition:=strWhereCondition
On Error Resume Next
DoCmd.Echo False 'Turn off screen painting
DoCmd.SelectObject acReport, "PO Fax Report", True
DoCmd.PrintOut acPrintAll, , , , 2 'Print Two Copies
Me.SetFocus 'Return Focus to the form
DoCmd.Echo True 'Turn on screen painting
Exit_PrintPO_Click:
Exit Sub
Err_PrintPO_Click:
MsgBox Err.Description
Resume Exit_PrintPO_Click
End Sub
Steve, if it is possible to perform both functions (print
current record and print two copies) I suppose I have some
syntax in the wrong order, or I am missing some code. Can
you give me some advice on how to correct this?
Thank you so much for your time.
-----Original Message-----
When you say print report button, I assume that this is a button on a form.
Here's one way to do that; if you'd like to give your
user's the ability to
select a printer at the same time you might stop by our
web site and look at
- Hide quoted text -
- Show quoted text -
our "On the Fly Printing" code which you can drop into your database and
have your solution in about 5 minutes.
But to print a couple of copy of a report from a button on a form use code
like that below by signature.
HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
--------------begin code-------------------
Sub MyButton_Click ()
On Error Resume Next
DoCmd.Echo False 'Turn off screen painting
Docmd.SelectObject acReport, "MyReportName", True
Docmd.PrintOut acPrintAll, , , , 2 'Print two copies
Me.SetFocus 'return focus to the form
Docmd.Echo True 'Turn on Screen painting
End Sub
news:f41501c21928$2acd5080
[email protected]...
- Hide quoted text -
- Show quoted text -
Steve Arbaugh
Jun 22 2002, 4:54 am show options
Newsgroups: microsoft.public.access.reports
From: "Steve Arbaugh" <
[email protected]> - Find
messages by this author
Date: Sat, 22 Jun 2002 06:51:50 -0400
Local: Sat, Jun 22 2002 4:51 am
Subject: Re: Printing more than one copy of a report-HELP!
Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse
Cathy:
Unfortunately, the two pieces of code are mutually exclusive unless
you
preview the report first. (So rather than using acViewNormal, use
acViewPreview, which allows the filter to run, then use PrintOut.)
Alternately you can use do OpenReports in a loop like this:
For i = 1 to NumPrints '2 if that's what you desire
doCmd.OpenReport "MyReport", acViewNormal
DoEvents
Next i
Or if you are really adventurous, you would put the number of copies
into
the dmCopies element of the prtDevMode property, (a bit of coding is
required).
Our on the Fly Printnig code would do all of this with few lines of
code
like:
Dim objPrint as New PrintClass
With objPrint
.ReportName = "PO Fax Report"
.FilterSQL = "PONumberID = " & Me!PONumberID
.Copies = 2
.PrintRpt
End With
HTH
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
- Hide quoted text -
- Show quoted text -
Thanks for the code Steve!
I tried it and it worked fine. Unfortunately, however, I
already have the following code for the Click event of
that button to print the current record, rather than all
records.
I take it you cannot have both actions happening in the
event because it ignored the first action and performed
the second resulting in all the forms being printed on the
report instead of the current one, but 2 copies were being
printed.
The code for the Click event is layed out like this:
Private Sub PrintPO_Click()
On Error GoTo Err_PrintPO_Click
Dim stDocName As String
Dim strWhereCondition As String
strWhereCondition = "PONumberID = " & Me!PONumberID
stDocName = "PO Fax Report"
DoCmd.OpenReport stDocName, acViewNormal, _
WhereCondition:=strWhereCondition
On Error Resume Next
DoCmd.Echo False 'Turn off screen painting
DoCmd.SelectObject acReport, "PO Fax Report", True
DoCmd.PrintOut acPrintAll, , , , 2 'Print Two Copies
Me.SetFocus 'Return Focus to the form
DoCmd.Echo True 'Turn on screen painting
Exit_PrintPO_Click:
Exit Sub
Err_PrintPO_Click:
MsgBox Err.Description
Resume Exit_PrintPO_Click
End Sub
Steve, if it is possible to perform both functions (print
current record and print two copies) I suppose I have some
syntax in the wrong order, or I am missing some code. Can
you give me some advice on how to correct this?
Thank you so much for your time.
End of messages