I have VBA routine that either previews or prints a series of eight reports, one for each "Agency". Whether to print or preview is dependent upon a global boolean (chkPreview).
The db is, and must be, in AC2003 format. However, I develop and run it in AC2007. I no longer have AC2003 installed on my machine (company policy).
My problem is that when chkPreview is true, the routine only previews the first Agency's report. When I close it, it does not open the other Agency's reports for preview. I am quite sure that previously (under AC2003) I would get a preview of each report.
When chkPreview is false, the routine correctly prints the complete series of reports.
I think AC2007 is getting in my way, but I may be overlooking something.
Any ideas??
The db is, and must be, in AC2003 format. However, I develop and run it in AC2007. I no longer have AC2003 installed on my machine (company policy).
My problem is that when chkPreview is true, the routine only previews the first Agency's report. When I close it, it does not open the other Agency's reports for preview. I am quite sure that previously (under AC2003) I would get a preview of each report.
When chkPreview is false, the routine correctly prints the complete series of reports.
I think AC2007 is getting in my way, but I may be overlooking something.
Any ideas??
Code:
Option Compare Database
Option Explicit
Dim chkPreview As Boolean
Private Sub PrintReport(stDocName As String)
On Error GoTo Except
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT DISTINCT Federal_Tables_Monitor.Agency FROM Federal_Tables_Monitor;", CurrentProject.Connection
While Not rs.EOF
DoCmd.OpenReport stDocName, IIf(chkPreview, acViewPreview, acViewNormal), , "Agency = '" & rs!Agency & "'"
rs.MoveNext
Wend
Finally:
rs.Close
Set rs = Nothing
Exit Sub
Except:
MsgBox Err.Description
Resume Finally
End Sub