Report Printout Question

  • Thread starter Thread starter Jay
  • Start date Start date
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.
 
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
 
Back
Top