Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running two reports simultaneously

Status
Not open for further replies.

itsuit

IS-IT--Management
Apr 23, 2002
53
US
Access 2000

Some background: I run two reports; one is a check, the other is backup information for the check (the two are linked on a field, "CHECK_KEY"). Depending on the day, there may be 250 checks plus backups to be run. Currently we have to combine the two by hand, which takes hours.

I've been able to run the reports simultaneously from different printer trays (set in the report's page setup) using the following code behind a button on a form:

Private Sub Command0_Click()
stDocName = "Report1"
DoCmd.OpenReport stDocName, acNormal
stDocName = "Report2"
DoCmd.OpenReport stDocName, acNormal

End Sub

This works when there is only one matching record in each report's underlying query. When there is more than 1 record, it runs all the checks, then all the backups.

What I need is to be able to iterate through the records, so I can print the first check, then the first backup, then the next check, the next backup, etc. I found the following sample code, but it's not working for me:

Sub Iterate()
Dim db As dao.Database
Dim rs As dao.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("select * from Table1")
rs.MoveFirst

Do Until rs.EOF
DoCmd.OpenReport "Report1", acViewNormal, , "pkID = " & rs!pkID
DoCmd.OpenReport "Report2", acViewNormal, , "pkID = " & rs!pkID
If Not rs.EOF Then rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub

Does anybody have suggestions? I'm desperate to get this working. Thanks in advance.

Kyle
 
Couldn't you make the second report a subreport of the first, thus you'd print your 1st check, all the backup info, second check, all its backup info...

Am I missing something??

HTH
Ben
 
I tried that, but couldn't get the subreport to print from a different printer tray (the checks print on check stock, the backup prints on plain paper).

That's why I need to run them as separate reports. Sorry to have left this out in my earlier post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top