knifelong
12-12-2012, 04:37 AM
Hi
I'm running multiple reports with VBA DoCmd.OutputTo method.
However I sometimes get two specific errors, A 2501 no records error which causes the procedure to exit and a 3146 odbc call failed which also causes the procedure to exit.
I would like to handle it so that when I get the 2501 error then it ignores the error and moves to the next report and when I get the 3146 error it runs the same report again as it failed.
However I'm not sure the best way to ignore the error and to get the same report to run again.
thanks
On Error Resume next
DoCmd.OutputTo acOutputReport, "my report", acFormatRTF, "C:\report.rtf", False
if Err.Number = 2501 Then
' ignore error
Else
if Err.Number = 3146 Then
Resume
End If
On Error Goto 0 'turn error reporting back on
I'm running multiple reports with VBA DoCmd.OutputTo method.
However I sometimes get two specific errors, A 2501 no records error which causes the procedure to exit and a 3146 odbc call failed which also causes the procedure to exit.
I would like to handle it so that when I get the 2501 error then it ignores the error and moves to the next report and when I get the 3146 error it runs the same report again as it failed.
However I'm not sure the best way to ignore the error and to get the same report to run again.
thanks
On Error Resume next
DoCmd.OutputTo acOutputReport, "my report", acFormatRTF, "C:\report.rtf", False
if Err.Number = 2501 Then
' ignore error
Else
if Err.Number = 3146 Then
Resume
End If
On Error Goto 0 'turn error reporting back on