OutputTo command problem

  • Thread starter Thread starter Cahrella
  • Start date Start date
C

Cahrella

I am trying to create a copy of a report in word after displaying it on the
screen. After saving another form is then displayed. It is left to the user
to decide where to save the word document. The following code works fine if
the user selects ok on the form after selecting where to save the report.
However if the user decides to cancel the save I get a runtime error 2501 and
the following form is not displayed. Is there any way of stopping the runtime
error from being displayed and allowing the next line of code to be processed.


DoCmd.OpenReport "Added Since Date report", acViewPreview
DoCmd.Maximize
DoCmd.OutputTo acOutputReport, "Added Since Date Report", acFormatRTF, , False
DoCmd.OpenForm "DisplayOrPrintReport", , , , acFormEdit, acDialog

Thanks
 
Hi Cahrella,

on error goto err_hand

DoCmd.OpenReport "Added Since Date report", acViewPreview
DoCmd.Maximize
DoCmd.OutputTo acOutputReport, "Added Since Date Report", acFormatRTF, , False
DoCmd.OpenForm "DisplayOrPrintReport", , , , acFormEdit, acDialog

exit sub

err_hand:
if err=2501 then
resume next
endif

So if error 2501 is raised the execution of the program continue from the
line following the offending line.

HTH Paolo
 
Back
Top