Printing Multiple Copies of a Report Form.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the syntax to send mulitple copies of a report to the printer.
Example or sample ?
I am using a HP Laser 4200 printer.

Thank You.
 
What is the syntax to send mulitple copies of a report to the printer.
Example or sample ?
I am using a HP Laser 4200 printer.

Thank You.

Look up the PintOut method in VBA help.
 
Fred, below is a sample of the code you assisted me the PrintOut Method.Dim
stDocName As String
DoCmd.RunCommand acCmdSaveRecord
Dim Message, Title, Default, PrintCopies
Message = "Enter Number of Copies" ' Set prompt.
Title = "Print Operator Daily Call Sheet" ' Set title.
PrintCopies = InputBox(Message, Title) ', Default)
stDocName = "rptOperatorDailyCallSheet-2"
DoCmd.OpenReport stDocName, acPrint
DoCmd.PrintOut , , , , PrintCopies, ' 0 ' 0=not collated

The PrintOut method is printing the report and form on the screen.
It is print one copy of the report and additional copies of the screen form.
For example. Copy input is (3) 1 copy of the report and 2 copies of the
screen form.

What adjustments need to be made.
 
Fred, below is a sample of the code you assisted me the PrintOut Method.Dim
stDocName As String
DoCmd.RunCommand acCmdSaveRecord
Dim Message, Title, Default, PrintCopies
Message = "Enter Number of Copies" ' Set prompt.
Title = "Print Operator Daily Call Sheet" ' Set title.
PrintCopies = InputBox(Message, Title) ', Default)
stDocName = "rptOperatorDailyCallSheet-2"
DoCmd.OpenReport stDocName, acPrint
DoCmd.PrintOut , , , , PrintCopies, ' 0 ' 0=not collated

The PrintOut method is printing the report and form on the screen.
It is print one copy of the report and additional copies of the screen form.
For example. Copy input is (3) 1 copy of the report and 2 copies of the
screen form.

What adjustments need to be made.

If you Dim variables, you should also set their types, otherwise they
are all going to be Variant.
You had incorrect parenthesis within the InputBox function.
You had the Collate argument within single quotes which would make it
a string. It must be a number.
If you just wish to print the report, there is no need to open it in
preview.

Dim stDocName As String

Dim strMessage as String, strTitle as String
Dim intDefault as Integer, intPrintCopies as Integer

intDefault = 1 ' You do want at least one copy printed, don't you?
strMessage = "Enter Number of Copies" ' Set prompt.
strTitle = "Print Operator Daily Call Sheet" ' Set title.
intPrintCopies = InputBox(Message, Title, Default)
stDocName = "rptOperatorDailyCallSheet-2"

DoCmd.RunCommand acCmdSaveRecord

DoCmd.SelectObject acReport, stDocName, True
DoCmd.PrintOut acPrintAll, , , , intPrintCopies, 0


The whole procedure can be shortened to the following:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.SelectObject acReport, "rptOperatorDailyCallSheet-2"
DoCmd.PrintOut acPrintAll, , , , InputBox("Enter Number of Copies", _
"Print Operator Daily Call Sheet",1), 0

Look up the SelectObject in VBA help.
 
Thanks Fred,

This is great, but I am getting an error message

"The Object "rptOperatorDailyCallSheet-2" isn't open.
 
Hi Fred,

I resolve the error message by adding "True" to the SelectObject method.

But I am having two problems.

1 -I am unable to cancel the InputBox prompt. It still print even though i
cancel.
2 - The Database box is popping up every time I running this code.

Thanks
Ileana
 
Hi Fred,

I resolve the error message by adding "True" to the SelectObject method.

But I am having two problems.

1 -I am unable to cancel the InputBox prompt. It still print even though i
cancel.
2 - The Database box is popping up every time I running this code.

Thanks
Ileana



Try something like this.

On Error GoTo Err_Handler

DoCmd.RunCommand acCmdSaveRecord

Dim intPrintOut As Integer
intPrintOut = InputBox("Enter Number of Copies", _
"Print Operator Daily Call Sheet", 1)
If intPrintOut > 0 Then
DoCmd.SelectObject acReport, "rptOperatorDailyCallSheet-2", True
DoCmd.PrintOut acPrintAll, , , , intPrintOut, 0
End If

Exit_Sub:
Exit Sub

Err_Handler:
If Err = 13 Then
MsgBox " Incorrect or no input entry." & vbNewLine & "Cancelling
the Report."
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub

I have no idea what you mean by
"The Database box is popping up every time I running this code."
What is a database box?
If you mean the InputBox, it's supposed to.
 
For some reason the inputbox function is not return a zero-length string. I
tested is with msgbox and it returns a blank. So trapping the error with 0
does not work.
I tried vbCancel and vbOkay. vbCancel nothing prints at all. I try testing
this on new database with the same results. Can trap the blank return?


When I use the "SelectObject" it cause the database dialog box to pop up.
The database dialog box is the box that contain the preview, design and new
for the Database Objects. Example Table, Query, Form, Report, Page.
 
For some reason the inputbox function is not return a zero-length string. I
tested is with msgbox and it returns a blank. So trapping the error with 0
does not work.
I tried vbCancel and vbOkay. vbCancel nothing prints at all. I try testing
this on new database with the same results. Can trap the blank return?

When I use the "SelectObject" it cause the database dialog box to pop up.
The database dialog box is the box that contain the preview, design and new
for the Database Objects. Example Table, Query, Form, Report, Page.
I have no idea what you are doing. If you care to create a new
stripped down database, with just enough data to run the report as
well as the report itself and send it to me, I will take a look at it.
Include whatever form you are using with the code.

Please do not send any sensitive data or private information.
Include a brief note tell me again what you are trying to do, as well
as what it is doing or not doing, and I will get back to you here in
the newsgroup.

Send it to
jandf at adelphia dot net
Make sure the subject line reads
"Fix database"
otherwise I will never see it.
 
I revised the code a little bit and resolve the problem.
The SelectObject was a problem, but your input was very helpfully.

Thank You
Fred


DoCmd.RunCommand acCmdSaveRecord
Dim intPrintOut
intPrintOut = InputBox("Enter Number of Copies", _
"Print Operator Daily Call Sheet", 1)
If intPrintOut = "" Then Exit Sub
DoCmd.OpenReport "rptOperatorDailyCallSheet-2", acPreview
DoCmd.PrintOut acPrintAll, , , , intPrintOut, 0

This works fine.
 
Back
Top