Strange problem with DoCmd.OutputTo

B

Bill Johnson

I'm using Access 2007 with Windows XP. I'm sending two reports in Snapshot
Format to a folder. For some strange reason one of the reports kicks me out
of the VB code without even producing an error. I switched the order of the
two reports and I still get kicked out by the same report. The code produces
both the files when I put the problem report second and only the first report
when I put that command first.

Private Sub Export_Report_Click()
On Error GoTo Err_Export_Report_Click

Dim stRpt1 As String
Dim stRpt2 As String
Dim stPath1 As String
Dim stFile1 As String
Dim stFile2 As String

stRpt1 = "rptSummarySheet"
stRpt2 = "rptGLAnalysis"
stPath1 = "C:\ACL Data\NRCS\SourceFiles\"
stFile1 = stPath1 & "GLSummarySheet1.snp"
stFile2 = stPath1 & "GLAnalysis.snp"

DoCmd.OutputTo acOutputReport, stRpt2, acFormatSNP, stFile2

MsgBox "Your Report has been saved to: " & stPath1 & stFile2

DoCmd.OutputTo acOutputReport, stRpt1, acFormatSNP, stFile1

******************************************************
********** NOTHING PAST THIS POINT RUNS ******************
******************************************************
MsgBox "Your Report has been saved to: " & stPath1 & stFile1

Exit_Export_Report_Click:
Exit Sub

Err_Export_Report_Click:
MsgBox "You have encountered an error. " & Chr(10) & Chr(13) & _
"Error Number: " & Err.Number & Chr(10) & Chr(13) & _
"Error Description: " & Err.DESCRIPTION

End Sub

I get what I need out of this routine, but this is puzzling.

Any help?
 
B

Bill Johnson

In case anyone has an issue similar to this one:

The report that would not allow the code to finish had it's own On Load
code. Whenever it would run it would run that code and never return to the
"parent" code from my form. Once I removed the report's On Load code this
problem was corrected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top