Copies to print based on a control

kilobyte

Registered User.
Local time
Today, 13:57
Joined
Oct 5, 2005
Messages
52
Hey everyone, merry christmas.

I have a question.

I have a report that shows a detail for each district in a zone. The report forces a new page for each zone. So there are usually 3-4 details on a page.

The report is designed for the district leaders, so I need to find a way to easily print one copy for each.

So I would like to have it print a different number of copies of each page equal to a control (count of the records) located in the zone footer.

Using the DoCmd.Printout seems to be the right idea, but when I reference the control with the count it returns only the highest number.

You follow? Hopefully that makes sense.

Anxiously awaiting floods of wisdom,

Dave
 
I believe the only way you can do this is if a) the count control is bound to report recordset, and b) you are using subreports to display the zone and district information.

If this is the case, you can add the following line to your code where appropriate:

DoCmd.GoToRecord , , AcNext

This will cycle to the next record and return the corresponding number from the count field. Remember, it's looking at the FIELD, not the CONTROL.

Hope this helps.
 
Thanks for responding x0reset, but I don't think I understand.

So you're saying I need to make my count control bound to something in the recordset?

Also, I don't think I explained very well that there is only one record per district. So if there are four records in the zone grouping (the only grouping level) I need that page to print four times.

Anyway, I think the main thing here is I don't know what you are talking about. (My bad). Could you please elaborate?
 
Last edited:
Say you have this as the dataset for your main report:

District_Leader_ID
Zone_Count

This gives the main report a primary key referencing the district leaders, and a count of the number of pages each needs to receive.

The dataset for your subreport should include:

District_Leader_ID
Zone_ID
Random_District_Info
etc...

Link the main report and the subreport using the District_Leader_ID. Now, in the "On Open" event of your report, add the following code:

Dim Count as Integer

While Not IsNull(Me.RecordSet.CurrentRecord)
Count = Me.Zone_Count
DoCmd.Printout , , , , Count
DoCmd.GoToRecord acNext
End While

This will print a number of copies equal to the number in the current records Zone_Count, then go to the next record and repeat. You will also have to do some creative page breaking and use variables to specify the print range in the DoCmd.Printout command so you dont print the entire report for every district leader. Also, I'm not absolutely certain the criteria I specified for the While loop will work, but it should point you in the right direction.
 

Users who are viewing this thread

Back
Top Bottom