Runtime errors- OpenReport

G

Guest

Hi. I have reports that allow for user input (such as a date) and then run
the report using the preview command. If the user begins to run the report,
but then decides not to run it and closes the parameter window, I get an
error message:

Runtime error 2501: the OpenReport action was canceled.

Similarly, I have mail labels that not only call an imput parameter, but
also open a form to allow the user to choose label size. If this "font" form
is closed prior to completing the entire report run, I get an error:

Runtime error 2450: can't find the form "font"...

Private Sub cmdPreview_Click()
DoCmd.OpenReport Report_Name, acPreview
End Sub

and

Private Sub Report_Open(Cancel As Integer)
....
DoCmd.OpenForm "Font", , , , , acDialog
....

Is there a way to make it look seamless to the user so that the parameter
form/"font" form and report closes without an error notification? Thanks for
your help!
 
A

Albert D.Kallal

Just trap the error in the openreprpt rouitnes

eg:

Private Sub cmdPreview_Click()
on error resume next
DoCmd.OpenReport Report_Name, acPreview
End Sub
 

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