Code to preview multiple instances of a form

T

terry w

Greetings to all
I have a form with a button cmdPrint. The click event has code including
DoCmd.OpenReport strDocName,acViewPreview
The report prints properly when clicked.

I have added another button called cmdPrint_FullSet. When clicked, I use
criteria in the form's controls to cycle through a set of reports that should
print. This cycling also works just fine. In each cycle, a 'Call
cmdPrint_Click' statement is executed.

My problem is that ony the first report preview is shown. I'm guessing this
is because they would all have the same file name. Is there a way to have
multiple instances of the report in Preview mode?

Terry W.
 
M

Marshall Barton

terry said:
I have a form with a button cmdPrint. The click event has code including
DoCmd.OpenReport strDocName,acViewPreview
The report prints properly when clicked.

I have added another button called cmdPrint_FullSet. When clicked, I use
criteria in the form's controls to cycle through a set of reports that should
print. This cycling also works just fine. In each cycle, a 'Call
cmdPrint_Click' statement is executed.

My problem is that ony the first report preview is shown. I'm guessing this
is because they would all have the same file name. Is there a way to have
multiple instances of the report in Preview mode?

You can do that, but things get tricky. The first thing to
do is adapt the stuff in http://allenbrowne.com/ser-35.html
to your report.

Then you will want to filter the data for each instance of
the report in different ways. Since you are not using
OpenReport, you can not use the WhereCondition argument for
the filtering. Instead, you can construct an appropriate
SQL statement and set an instance's RecordSource OR set its
Filter property.

One thing to note is that you may be satisfied with just
opening a single instance of the report and use separate
buttons on your form to change the report's Filter property
when a user wants to view the date with a different filter.
That is usually ok because it rare for two reports to be
small enough for users to able to see both of them at the
same time.
 

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