Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the report to print 2 copies using criteria 1

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
How can I tell a report to print 2 copies using criteria.

I will be doing something like this...

If Me.mytextBox = "mycriteria" Then
"Print 2 Copies??"
End If

Thank you in advance for any help...
 
Hi,
The simplest solution is to loop through the number of times selected by the user, and run the report "x" times. Of course, a "for...next" loop is perfect for this. Presuming that the number of copies appears on your form as txtCopies, here is what the code might look like:

for i = 1 to txtCopies
DoCmd.OpenReport ...........
next i HTH, [pc2]
Randy Smith
California Teachers Association
 
Actually I was hoping there was a way to do it from the reports module somewhere. I want the report to look at a field called ServiceType. The serviceType's would be "Filing", "Delivery", "Pick-Up" etc..., but when the report is a filng..ie...Me.[TypeOfService]= "Filing", then I need 2 copies of the report.
 
Hi,
There is a PrintCount property for the report, but when I try to run it from the Activate event (as well as the Open event) for the report, I get the following error message: "property is read only, and can't be set".
Here is the code:
Report.PrintCount = 2 HTH, [pc2]
Randy Smith
California Teachers Association
 
I am getting errors also, but I did think of a better idea for exactly what I am trying. I put what I want for the filing in the ReportFooter instead of needing 2 copies. Maybe you could help me with this. If I have a ReportFooter that I only want printed when the TypeOfService is a Filing, then how and where would I put that? I have tried:

On Retreat
If Me.txtTypeOfService = "Filing" Then
Me.ReportFooter.Visible = False
Else
Blah Blah Blah!
End If

And have also tried it in the On Format event.

But it prints the ReportFooter for everything still. It basically ignores my code, but doesn't give me an error.
 
Hi,
Your headers and footers have a property called "Can Shrink" and "Can Grow". The default for these is set to No by Microsoft. By the way, the code for this should be placed in the OnFormat event. HTH, [pc2]
Randy Smith
California Teachers Association
 
Looks like I am getting close. I have put a GroupFooter that is only visible when the TypeOfService TextBox = "Filing". It is working great accept for one thing. When the GroupFooter isn't visible the report still prints the PageHeader and PageFooter. This is not the worst thing in the world, but it is an extra page that is not needed. Any suggestions?
 
By that I mean it prints an extra PageHeader and Footer, I presume, for the GroupFooter that is not visible. What I need is instead of the GroupFooter not being visible, I need it to not be there at all. I hope I am clear on this.
 
Hi,
Did you know that you can have only the "report header" and "report footer" appear, instead of the "page header" and "page footer"? So, this means that only the first page will have a header, and the last page.
I believe that you can also turn off the page header and footer whenever your group footer isn't visible. The code might look like this:
if Me!ReportFooter.visible = "false" Then
Me!PageHeader.visible = "False"
Me!PageFooter.visible = "False"
end If HTH, [pc2]
Randy Smith
California Teachers Association
 
That is something I haven't tried, and would work. Thanks for all your help. I am going to have to give this a run tomorrow.
 
WallT,

Regarding printing multiple copies, give this code a shot:
Code:
If Me.[TypeOfService]= "Filing" Then
   DoCmd.OpenReport "YourReportName", acViewPreview
   DoCmd.PrintOut , , , , 2
   DoCmd.Close  ' Close the report.
End If
 
I'm trying your last suggestion:

if Me!GroupFooter.visible = "false" Then
Me!PageHeader.visible = "False"
Me!PageFooter.visible = "False"

But I am getting an error that say's..."Invalid Qualifier"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top