OutputTo Snapshot Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using the following code in an Access 2k database to save some reports to
MS Snapshot files:

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,
, False
sSleep 1000
rst.MoveFirst
Do Until rst.EOF
Select Case rst!Survey_Type
Case "Warewash"
DoCmd.OutputTo acOutputReport,
"rptCustomerWarewash", acFormatSNP, , False
Case "Laundry"
DoCmd.OutputTo acOutputReport, "rptCustomerLaundry",
acFormatSNP, , False
Case "Ancillary"
DoCmd.OutputTo acOutputReport,
"rptCustomerAncillary", acFormatSNP, , False
Case "Housekeeping"
DoCmd.OutputTo acOutputReport, "rptCustomerHK",
acFormatSNP, , False
Case "Floor Care"
DoCmd.OutputTo acOutputReport, "rptCustomerFC",
acFormatSNP, , False
End Select
sSleep 1000
rst.MoveNext
Loop
sSleep 1000
DoCmd.OutputTo acOutputReport, "rptCustomerSummaryMain",
acFormatSNP, , False
Else
MsgBox "Please select a survey(s)"
Me.Visible = True
End If
End If
rst.Close

The code works fine if I step through it one line at a time. The code also
works fine if I open the form from the database window. However, if I open
the program as the user would and choose the tool from the main menu, the
first report is saved but when the second report comes up I receive an error:
"The command or action 'OutputTo' isn't available now." I tried entering code
to pause the process to give the report time to be saved but no matter how
long of a pause was entered the same error occured. The same code structure
also works fine if I use the RTF format. Something is obviously happening
with the Snapshot format. Can anyone help? Thanks.
 
I'm using the following code in an Access 2k database to save some reports to
MS Snapshot files:

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,
, False
sSleep 1000
rst.MoveFirst
Do Until rst.EOF
Select Case rst!Survey_Type
Case "Warewash"
DoCmd.OutputTo acOutputReport,
"rptCustomerWarewash", acFormatSNP, , False
Case "Laundry"
DoCmd.OutputTo acOutputReport, "rptCustomerLaundry",
acFormatSNP, , False
Case "Ancillary"
DoCmd.OutputTo acOutputReport,
"rptCustomerAncillary", acFormatSNP, , False
Case "Housekeeping"
DoCmd.OutputTo acOutputReport, "rptCustomerHK",
acFormatSNP, , False
Case "Floor Care"
DoCmd.OutputTo acOutputReport, "rptCustomerFC",
acFormatSNP, , False
End Select
sSleep 1000
rst.MoveNext
Loop
sSleep 1000
DoCmd.OutputTo acOutputReport, "rptCustomerSummaryMain",
acFormatSNP, , False
Else
MsgBox "Please select a survey(s)"
Me.Visible = True
End If
End If
rst.Close

The code works fine if I step through it one line at a time. The code also
works fine if I open the form from the database window. However, if I open
the program as the user would and choose the tool from the main menu, the
first report is saved but when the second report comes up I receive an error:
"The command or action 'OutputTo' isn't available now." I tried entering code
to pause the process to give the report time to be saved but no matter how
long of a pause was entered the same error occured. The same code structure
also works fine if I use the RTF format. Something is obviously happening
with the Snapshot format. Can anyone help? Thanks.

How about sprinkling some DoEvents in your code and see what happens.
_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
The problem was caused by the database window being hidden. I wrote code to
unhide the window before outputting the reports and code to hide it again
after the process was finished. No more errors.
 
Cool! Thanks for posting back with your success.

The problem was caused by the database window being hidden. I wrote code to
unhide the window before outputting the reports and code to hide it again
after the process was finished. No more errors.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
Back
Top