Batch printing based on Combo settings

T

terry w

hi - I have a form with 2 combo Boxes, cboA and cboB. The user selects a
value from both of these, then clicks a command Button, cmdPrint. This
prints a report based on the 2 selections. Typically, cboA has about 6 to 10
rows, and cboB has about 3 to 5 rows.

From time to time the users need to print ALL reports, which could mean
cycling through the procedure 50 times! I've added a new button,
cmdBatchPrint, but I'm having trouble getting its On_Click event code to
work. For each value of cboA, I need to print a report based on each value
of cboB. I need a way to dynamically 'walk through' all the combinations.
I'd really appreciate some clues - I'm still pretty new at coding.

Terry W.
 
J

John W. Vinson

hi - I have a form with 2 combo Boxes, cboA and cboB. The user selects a
value from both of these, then clicks a command Button, cmdPrint. This
prints a report based on the 2 selections. Typically, cboA has about 6 to 10
rows, and cboB has about 3 to 5 rows.

From time to time the users need to print ALL reports, which could mean
cycling through the procedure 50 times! I've added a new button,
cmdBatchPrint, but I'm having trouble getting its On_Click event code to
work. For each value of cboA, I need to print a report based on each value
of cboB. I need a way to dynamically 'walk through' all the combinations.
I'd really appreciate some clues - I'm still pretty new at coding.

Terry W.

The combo boxes will probably not be involved at all. What's the Recordsource
for the report? What code do you have in cmdPrint? I presume you're (somehow,
you don't say and we can't see) passing the combo boxes as criteria for the
report, either in the report's recordsource Query or in the OpenReport method
call; if you want to print all reports then... well... just don't use any
criteria or filtering on the report.
 
T

terry w

Hello John - sorry my info is so scanty. Lets say cboA has fields CityID
(bound) and CityName, and it shows Kalamazoo, Flint and Inkster. Lets also
say cboB has fields DeptID and DeptName and shows Sales and Accounting. When
I click cmdPrint, there is there is lots of code, but the important part
looks like...

Me.Filter = "CityID = " & cboA.Value & " AND DeptID = " & cboB.Value
Me.FilterOn = True
...
DoCmd.OpenReport strDocName, acViewNormal

Removing the filter stuff still results in just one report being printed,
whereas I need a separate report for each case. I think I need something
like this 'air code'...

For each row in cboA
For each row in cboB
Me.Filter = "CityID = " & cboA.Value & " AND DeptID = " & cboB.Value
Me.FilterOn = True
...
DoCmd.OpenReport strDocName, acViewNormal etc...

I just can't get the syntax right for the "For each row in cbo..." part.

Thankyou
Terry
 
J

John W. Vinson

Removing the filter stuff still results in just one report being printed,
whereas I need a separate report for each case.

Rather than opening the report umpteen times, I'd suggest changing the design
of the report. Remove its filter altogether, and use its Sorting and Grouping
property to put a page break after each change in either field. That will give
you separate *sheets of paper* for your users (a separate "report" if you
will) for each case. That would be a lot easier than a complex (and
inefficient) loop opening the report twenty times with twenty different
filters!
 

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