VBA And Error Routines (1 Viewer)

omccartney

Registered User.
Local time
Today, 09:34
Joined
Jun 4, 2007
Messages
14
I have some code that worked in 2000 but does not work in 2003/2007. It is the On Error Statement. When I run the code, it seems to ignore my On Error Statement and opens a VB Dialogue box that shows my error "Microsoft Office Assistant can't find the object 'SynnexMultiContact5'. I know why the data I am getting the error, but why is my error routine not being called? Below is the code.

Private Sub subImportData2()
On Error GoTo BooBoo

DoEvents
' Reset data table -------------------------------------------------------
DoCmd.DeleteObject acTable, "SynnexMultiContacts5"

Exit Sub
BooBoo:
MsgBox "Error: " & Err.Number & "-" & Err.Description
Err.Clear
Exit Sub

End Sub
 
I just pasted it into a form module and called it with a button and it generated the error. Where do you have it and how are you calling it?

Edit:Ignore that. I didn't check it in 2003 or 2007.
 
Do you have break on all errors set?
 
I just tested it in 2007 and it works for me; it goes to the error handler and brings up the error message.
 
Chris0 - I am having the same problem with every routine that has an on error. Not all of my routines have an on error.

BobLarson - That would lead me to believe perhaps I have some option turned on/off in 2007. :p Any ideas?
 
In the VBE window go to Tools > Options and the General tab to see what your Error Trapping setting is.
 
When I have it set to "Break on All Errors" I get the dialog box with the End/Debug/Help answer buttons. If I have it set to "Break in Class Module" or "Break on Unhandled Errors" I get the dialog box with only the "OK" answer button.
 
are you getting the error twice

i am not sure about err.clear

i thought you need a resume in a error handler to reset the error trap, otherwise it is not active the second time

hope this isnt too tortuous to understand
 
It is the first time. You do not need a resume if the routine terminates after the error.
 
I have even tried building a 2007 accdb from scratch and re-typing the code and still have the same problem. :confused:
 
omccartney

When you say “If I have it set to “Break in Class Module" or "Break on Unhandled Errors" I get the dialog box with only the "OK" answer button.” What is the content of the message box? Does it display the error number and the error description?
 
omccartney

When you say “If I have it set to “Break in Class Module" or "Break on Unhandled Errors" I get the dialog box with only the "OK" answer button.” What is the content of the message box? Does it display the error number and the error description?

I have the same question because that's exactly what I get and that's what you SHOULD get.
 
Thanks for your help. I ran a test on another PC here at my office and it works on that PC as it did for you. Must be something specific to that PC. Always make sure the monitor is plugged in first! :o
 

Users who are viewing this thread

Back
Top Bottom