Link to home
Start Free TrialLog in
Avatar of Ralph Gould
Ralph GouldFlag for United States of America

asked on

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'
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

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?
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.
Avatar of Ralph Gould

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks folks for fast, effective response even though I posted to the wrong place