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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing multiple copies of a report 1

Status
Not open for further replies.

Skyshadow5

Technical User
Mar 27, 2002
53
GB
My report is based on a query. One of the query fields has a Parameter value that needs to be entered when either the query or report is run. From a switchboard button I need the report to print 3 copies once the parameter value has been entered. Is this possible and if so how?
Thanks in advance.

Clive
 
The easy approach I used was to simply execute a little For Loop... psuedo code below.

For x = 1 to 3
doCmd.report....
Next x

htwh Steve Medvid
"IT Consultant & Web Master"
 
Thanks for the reply Steve, unfortunatley it didn't work. I got an error message stating "Compile error: Variable not defined". It highlighted the first line in yellow and the cursor was on the x in "For x = 1 To 3"

This is what the code is:
Private Sub Print_Corporate_Remittance_Advice_button_Click()
On Error GoTo Err_Print_Corporate_Remittance_Advice_button_Click

Dim stDocName As String

stDocName = "Corporate Remittance Advice"
For x = 1 To 3
DoCmd.OpenReport stDocName, acNormal
Next x

Exit_Print_Corporate_Remittance_Advice_b:
Exit Sub

Err_Print_Corporate_Remittance_Advice_button_Click:
MsgBox Err.Description
Resume Exit_Print_Corporate_Remittance_Advice_b

End Sub

Once I press the button, I need it to prompt me for the data to enter, then proceed to print three copies based on that data. If I were to open the report in preview mode I would get the parameter prompt, enter the data, ok that and it would display. I would like to go straight to print with 3 copies after entering the prompt data.
Sorry this is so long, help please.

Clive
 
Steve, I am no programmer and do not delve into coding as I haven't really got a clue what it is all about. I will take an educated guess sometimes and occasionally get it right. I know this sounds a bit thick, but could you add your code to what I entered above so I can see where it is you would place it, thanks.

Clive
 
no problem... good to hear you are willing to learn this stuff...

Private Sub Print_Corporate_Remittance_Advice_button_Click()
On Error GoTo Err_Print_Corporate_Remittance_Advice_button_Click

Dim stDocName As String
Dim X as Integer

stDocName = "Corporate Remittance Advice"
For x = 1 To 3
DoCmd.OpenReport stDocName, acNormal
Next x

Exit_Print_Corporate_Remittance_Advice_b:
Exit Sub

Err_Print_Corporate_Remittance_Advice_button_Click:
MsgBox Err.Description
Resume Exit_Print_Corporate_Remittance_Advice_b

End Sub

Steve Medvid
"IT Consultant & Web Master"
 
Thanks for your help Steve. This nearly works. After clicking the Print button, the dialog box pops up asking for the parameter value, I enter the value, it sends the report to the printer but then asks for the parameter again and hence a third time. Need to find a way to print x 3 after entering the parameter value.

Clive
 
Now you are getting a little more involved into programming. There is noway to accomplish that without programming...

First make a complete backup of the database (.mdb) before changing anything.

Here is an overview of what you will need to do;
1. Remove the PARAMETERS statement from the Query used to generate the report. Test the query to make sure it returns all the data.

2. Within the code I sent u... After the Dim statements enter the following:
===========
Dim strInput As String
Dim strMsg As String
Dim lcWhere as String
strMsg = "Enter your parameter value."
strInput = InputBox(Prompt:=strMsg, Title:="Parameter Info", XPos:=2000, YPos:=2000)
MsgBox "Params: " & strInput 'Delete this line later.
lcWhere = "[FieldName] = '" & strInput & "'"
===========
You now have a variable with your Parameter entry.

3. Within the statement
"DoCmd.OpenReport stDocName, acNormal"
you will need to add a Filter.
"DoCmd.OpenReport stDocName, acNormal, , lcWhere"

htwh... Don't think I can add any more at this point..
Steve Medvid
"IT Consultant & Web Master"
 
Cheers Steve, I'll give it a go and let you know what happens.

Clive
 
If the above works for you, great. There's also another, little-known method that allows you to do this too:

DoCmd.PRINTOUT /start-page /end-page /quality /number-of-copies

I use this with a little "Print control panel" that lets the user enter start page, end page, and number of copies, which I then pass to this method. Seems to work ok.

Ex-JimAtTheFAA
78.5% of all statistics are made up on the spot.
Another free Access forum:
 
Steve, you're a star. Thanks for your help, it works a treat. I do have another query to add to my problem, I'll come to that in a bit.

Wildhare, thanks for your tip as well. If you've read all of this thread you'll see I'm not an expert (just trying to be!) and would love to learn as much as poss, ould you mind expanding on your solution to my problem. I'm also interested in your "Printer Control Panel" and would like to know if I can integrate this approach into another couple of problems I'm rying to resolve.

Steve, now that (with your help) I've got my report to print, what I would really love to do is limit the number of records that actually get printed by being able to select them with, say, a list that appears of all available records (based on the query first, then the parameter value) then being able to click a check box next to the items in the list that I want included.
So, to summarize, I click the Print button, enter the parameter value, then a list would appear with check boxes by the side, I check the items I want to print or check one box that incldes everything, click ok and it prints 3 copies with just the selected records.
I know this is asking a lot but you have been really helpful so far, can you help again?

Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top