Error Handling - Please help

baloos

Registered User.
Local time
Today, 09:54
Joined
Dec 1, 2002
Messages
21
In my error handling I am referencing the DBengine.Errors collection to write trapped errors to a table, but it seems that some of the errors I trap are not included in this collection. :confused:

I have noticed that errors which can be referenced by the DBengine.Errors collection have in common that their error numbers begin with 3 eg "3021 - No Current Record".

Other Errors eg "2501 - The Close action was canceled." do not appear in the collection.

Can somebody explain what exactly determines whether or not a trapped error appears in the collection?

Any help appeciated, thanks.
 
There are a lot more errors than those with a "3" prefix. Check out the sample I posted at AccessAndJetErrors.zip for it will create a table that lists all jet errors [@ 1000] and their descriptions. I suggest that you write the err.number and err.description to the table for when you have an error to report.
 
After further investigation on my part it seems that there are at least three different types of error that I need to cater for.

DAO errors which can be referenced by the DBEngine.errors collection (and can contain more than one description). VBA errors who's description can be referenced by Err.description or Error(Err), and Access errors who's description can be referenced by AccessError(Err).

What I want to say in my generic error handling routine is along the lines of...

If DAO error then
.... for each error in collection
........ write to table
.... next error in collection
else
.... if this is a vba error
........ write to table (using description from Error(Err))
.... else
........ write to table (using description from AccessError(Err))
.... end if
end if

My problem is that there does not seem to be an easy way to distinguish between the three types of error.

Has anyone written a generic handler which does this?
 

Users who are viewing this thread

Back
Top Bottom