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
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"
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