OutputTo command problem

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
 
P

Paolo

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
 

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