How do I create a button that prints 2 copies of a form?

A

Adam - Regus

1. Adam - Regus
Feb 2, 10:48 am show options

Newsgroups: comp.databases.ms-access
From: "Adam - Regus" <[email protected]> - Find messages by this
author
Date: 2 Feb 2006 07:48:20 -0800
Local: Thurs, Feb 2 2006 10:48 am
Subject: How do I create a button that prints 2 copies of a form?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I'm trying to create a button that prints 2 copies of a form. Using
the wizard, I created a button that prints one automatically, using the

following code:


End Sub


Private Sub CSR_BeforeUpdate(Cancel As Integer)


End Sub
Private Sub PRINTFORM_Click()
On Error GoTo Err_PRINTFORM_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection


Exit_PRINTFORM_Click:
Exit Sub


Err_PRINTFORM_Click:
MsgBox Err.Description
Resume Exit_PRINTFORM_Click


End Sub


-------------------------------------END OF
CODE----------------------------------------------------


So anyone know how I can get it to print 2 copies automatically?


thanks for your help,


Adam
 
R

Rick B

As posted very often in this newsgroup, it is not a good idea to print a
form. Forms are designed for data viewing, entry, and editing. A report is
designed to print. It includes the appropriate controls and options needed
to better control what prints.

While this does not address how to get two copies, I'd suggest you build and
use a report instead.
 
R

Rick B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top