Report Printout Question

J

Jay

I have the following code in the OnOpen Event of my report:

Dim strRecordSource as string

strRecordSource = "SELECT * FROM tblExample1;"
Me.RecordSource = strRecordSource

strRecordSource = "SELECT * FROM tblExample2;"
Me.RecordSource = strRecordSource

strRecordSource = "SELECT * FROM tblExample3;"
Me.RecordSource = strRecordSource

strRecordSource = "SELECT * FROM tblExample4;"
Me.RecordSource = strRecordSource




Is there a way I can printout report. Change the
recordsource print out the same report upto 4 times.

I know I can't close the report because the OnOpen Event
will start over.
 
G

Guest

I should question why you have four different tables that seem to have the
same structure but I will assume you know what you are doing.

You could create a union query of the four table
SELECT *, 1 as Example
FROM tblExample1
UNION ALL
SELECT *, 2
FROM tblExample2
UNION ALL
SELECT *, 3
FROM tblExample3
UNION ALL
SELECT *, 4
FROM tblExample4;
Then use the union query as the record source of your report. Your code can
then be something like:
Dim intI as Integer
for intI = 1 to 4
DoCmd.OpenReport "rptName", acPrint, , "Example =" & intI
Next
 

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

Similar Threads


Top