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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lost preview of a series of reports 1

Status
Not open for further replies.

kzutter

MIS
May 6, 2005
38
US
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??

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
 
I would try add acDialog like:
Code:
    While Not rs.EOF
        DoCmd.OpenReport stDocName, IIf(chkPreview, acViewPreview, acViewNormal), , _
            "Agency = '" & rs!Agency & "'", , acDialog
        rs.MoveNext
    Wend

Duane
Hook'D on Access
MS Access MVP
 
Yippee!!!

That worked. I would have thought that it would trap me in modal hell.

Thanks,
Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top