On Error Resume Next not working

  • Thread starter Thread starter Dale Fye
  • Start date Start date
D

Dale Fye

Access 2003, SP2.

I've recently started having probems with several of my VBA routines not
working properly. I've got some in-line error checking in a couple of places
in an Access application and an Excel Macro.

In one instance, I use the following code to allow a Cancel if there is no
data for the report, but I get a "2501 OpenReport action was cancelled" error
message on the OpenReport line of code.

On Error Resume Next
DoCmd.OpenReport "rpt_Circular_References", acViewPreview
If Err.Number = 2501 then
msgbox "No data to display in report"
Else
msgbox err.number & vbcrlf & err.description
Endif
On Error Goto ReportHandler

In another instance I used the following lines of code to make sure that the
MyFile command bar did not exist, before creating it again, but got an error
on the line that does the deletion (when the command bar did not already
exist):

On Error Resume Next
application.Commandbars("MyFile").Delete
On Error Goto ReportHandler

Any ideas?
 
Dale Fye said:
Access 2003, SP2.

I've recently started having probems with several of my VBA routines not
working properly. I've got some in-line error checking in a couple of
places
in an Access application and an Excel Macro.

In one instance, I use the following code to allow a Cancel if there is no
data for the report, but I get a "2501 OpenReport action was cancelled"
error
message on the OpenReport line of code.

On Error Resume Next
DoCmd.OpenReport "rpt_Circular_References", acViewPreview
If Err.Number = 2501 then
msgbox "No data to display in report"
Else
msgbox err.number & vbcrlf & err.description
Endif
On Error Goto ReportHandler

In another instance I used the following lines of code to make sure that
the
MyFile command bar did not exist, before creating it again, but got an
error
on the line that does the deletion (when the command bar did not already
exist):

On Error Resume Next
application.Commandbars("MyFile").Delete
On Error Goto ReportHandler

Any ideas?


Check the VB Editor's option setting for Error Trapping -- make sure it's
not set to "Break on All Errors".
 
Dale said:
Access 2003, SP2.

I've recently started having probems with several of my VBA routines not
working properly. I've got some in-line error checking in a couple of places
in an Access application and an Excel Macro.

In one instance, I use the following code to allow a Cancel if there is no
data for the report, but I get a "2501 OpenReport action was cancelled" error
message on the OpenReport line of code.

On Error Resume Next
DoCmd.OpenReport "rpt_Circular_References", acViewPreview
If Err.Number = 2501 then
msgbox "No data to display in report"
Else
msgbox err.number & vbcrlf & err.description
Endif
On Error Goto ReportHandler

In another instance I used the following lines of code to make sure that the
MyFile command bar did not exist, before creating it again, but got an error
on the line that does the deletion (when the command bar did not already
exist):

On Error Resume Next
application.Commandbars("MyFile").Delete
On Error Goto ReportHandler


It sounds like you set Break on All Errors in the VBA Tools
- Options menu item, General tab.
 
Thanks, Dirk. That did it. I had changed it to break on all errors in
Excel, and didn't realize that it would translate over to Access as well.


--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
Dale Fye said:
Thanks, Dirk. That did it. I had changed it to break on all errors in
Excel, and didn't realize that it would translate over to Access as well.


I didn't know that, either, so it's good to learn. I guess it's the same
editor, regardless of application.
 
Hi every one. I had a similar problem where all on "error resume next"didn't launch as expected.
i saw a bit later that the cells (under excel) affected where the ones i played around with selection.play , so i deleted them and now it works again (i won't use the .play again).

i also had once a similar problem by using "if ... then (code) [enter] (more code)...end if" instead of "if ... then [ENTER] (code)... [enter] end if", and i found out that for more than one line after the "then", i needed to write my code starting at the next line and not on the same line (vba doesn't find it as an error but code application wil bug anyway in strange ways).

I hope i this can help at least one some of you. Bye
 
Back
Top