D
Dan
In an Access 2k database I'm using the OutputTo command to save a report to a
Snapshot file. This works fine as long as I only save one report and then
exit the routine. However, as soon as I attempt to loop through a recordset
containing various reports to be saved I receive an error: "The command or
action 'OutputTo' isn't available now." The first report in the list is saved
appropriately but as soon as the code attempts to output the second report
the error occurs.
The same code works fine if I save as acFormatRTF. Example code is below:
strSQL = "SELECT * FROM CustRptSelectReports WHERE
CustRptSelectReports.Select = yes " _
& "AND CustRptSelectReports.reportID = " & ReportID & ";"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
DoCmd.OutputTo acOutputReport, "rptCustomerCover", acFormatSNP
rst.MoveFirst
Do Until rst.EOF
Select Case rst!Survey_Type
Case "Warewash"
DoCmd.OutputTo acOutputReport,
"rptCustomerWarewash", acFormatSNP
Case "Laundry"
DoCmd.OutputTo acOutputReport, "rptCustomerLaundry",
acFormatSNP
Case "Ancillary"
DoCmd.OutputTo acOutputReport,
"rptCustomerAncillary", acFormatSNP
Case "Housekeeping"
DoCmd.OutputTo acOutputReport, "rptCustomerHK",
acFormatSNP
Case "Floor Care"
DoCmd.OutputTo acOutputReport, "rptCustomerFC",
acFormatSNP
End Select
rst.MoveNext
Loop
DoCmd.OutputTo acOutputReport, "rptCustomerSummaryMain",
acFormatSNP
Snapshot file. This works fine as long as I only save one report and then
exit the routine. However, as soon as I attempt to loop through a recordset
containing various reports to be saved I receive an error: "The command or
action 'OutputTo' isn't available now." The first report in the list is saved
appropriately but as soon as the code attempts to output the second report
the error occurs.
The same code works fine if I save as acFormatRTF. Example code is below:
strSQL = "SELECT * FROM CustRptSelectReports WHERE
CustRptSelectReports.Select = yes " _
& "AND CustRptSelectReports.reportID = " & ReportID & ";"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
DoCmd.OutputTo acOutputReport, "rptCustomerCover", acFormatSNP
rst.MoveFirst
Do Until rst.EOF
Select Case rst!Survey_Type
Case "Warewash"
DoCmd.OutputTo acOutputReport,
"rptCustomerWarewash", acFormatSNP
Case "Laundry"
DoCmd.OutputTo acOutputReport, "rptCustomerLaundry",
acFormatSNP
Case "Ancillary"
DoCmd.OutputTo acOutputReport,
"rptCustomerAncillary", acFormatSNP
Case "Housekeeping"
DoCmd.OutputTo acOutputReport, "rptCustomerHK",
acFormatSNP
Case "Floor Care"
DoCmd.OutputTo acOutputReport, "rptCustomerFC",
acFormatSNP
End Select
rst.MoveNext
Loop
DoCmd.OutputTo acOutputReport, "rptCustomerSummaryMain",
acFormatSNP