ms access vba bypassing/ignoring on error code

vba app in access 2k13 throws a err 7874 on a delete object docmd completely ignoring the on error procedure.

here is the code:

On Error GoTo Del_Error
DoCmd.DeleteObject acTable, "machine"  'remove source table
DoCmd.DeleteObject acTable, "repair"  'remove source table
DoCmd.DeleteObject acTable, "TrendHdr"  'remove source table
DoCmd.DeleteObject acTable, "trendmac"  'remove source table
DoCmd.DeleteObject acTable, "UPDrepair"

Call LogFileWrite("RSQueueEntryGet", "source tables deleted " & Now())
Bypass_Del:

Exit Function

Del_Error:
'MsgBox "delete error " & Err.Number & " " & Err.Description
 If Err.Number = 7874 Then   'table does not exist
        Err.Clear
        Resume Next
 End If

the error option is set to 'Break on unhandled errors'
jsgouldAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
A suggestion: In the future, when asking questions about Access VBA, you should specifically include the Access topics when posting. This question never appeared in the Microsoft Access topic area ...

When you say it's ignoring the error, do you mean it never falls to the Del_Error label, or that it does fall there, but does not execute properly afterwards?

Can you set a Breakpoint at the beginning of your code, and determine which code line it fails on?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
Open up the VBA editor window and click on tools, options, then the general tab.

Make sure error trapping is set to "Break on Unhandled Errors".

Jim.
0
jsgouldAuthor Commented:
Scott: it falls through the on error command and pops up the 7874 error on the first docmd.if I set next statement to each of the following docmds I get the same error

Jim: note in the issue description that I state that break on unhandled errors is set
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
I would simply do this:

' Delete the tables if they exist.  Ignore any warnings if they don't.
On Error Resume next
DoCmd.DeleteObject acTable, "machine"  'remove source table
DoCmd.DeleteObject acTable, "repair"  'remove source table
DoCmd.DeleteObject acTable, "TrendHdr"  'remove source table
DoCmd.DeleteObject acTable, "trendmac"  'remove source table
DoCmd.DeleteObject acTable, "UPDrepair"
On Error Goto Del_Error
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Agreed with Jim - there's no reason to even involve error handling if you're going to ignore it.

FWIW - you could check to be sure the object exists before you remove it, but that's something of a waste of time (since your only action after checking is to remove it).

You could also use straight SQL to do this:

Currentdb.Execute "DROP TABLE machine"
Currentdb.Execute "DROP TABLE repair"
etc etc
0
jsgouldAuthor Commented:
Thanks folks for fast, effective response even though I posted to the wrong place
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.