Ralph Gould
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("RSQueueEntry Get", "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'
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("RSQueueEntry
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'
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.
Make sure error trapping is set to "Break on Unhandled Errors".
Jim.
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
Jim: note in the issue description that I state that break on unhandled errors is set
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks folks for fast, effective response even though I posted to the wrong place
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?