Error Description

KenHigg

Registered User
Local time
Today, 17:11
Joined
Jun 9, 2004
Messages
13,310
How do I retrieve an error description if there is no actual error. I know how to get it when an error is thrown - err.description. But say all I have is the error number like 3011.

???
ken
 
In the immediate window type

?Error(3011)

or

?Accesserror(3011)
 
Hum - recon that'll work in code at runtime?

ken

edit:

Even in immediate it gives me the generic "Application-defined or object-defined error" msg regardless of the error number...
 
Hum - recon that'll work in code at runtime?

ken

edit:

Even in immediate it gives me the generic "Application-defined or object-defined error" msg regardless of the error number...

You need to use AccessError for some (most) of the higher number error numbers.

When I type in AccessError(3011) I get this:

Code:
?accesserror(3011)
The Microsoft Jet database engine could not find the object '|'.  Make sure the object exists and that you spell its name and the path name correctly.
 
Hum. So I have to do a funct to raise it, get the description and pass it back?

ken
 
Ken,

In Access 2003, the highest error number is 10,973.

You can stuff them all into a table using something like:

tblAllErrors
============
id - AutoNumber
ErrorNumber - Long Integer
ErrorText - Memo

Code:
Dim i As Long
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("Select * From tblAllErrors")
For i = 0 To 20000
   rst.AddNew
   rst!ErrorNumber = i
   rst!ErrorText = AccessError(i)
   rst.Update
   Next i

Then if you remove all of the blank messages, you get 4,080.
Then remove "Application-defined or object-defined error" leaving 2,168.

There's a lot of unused Error Numbers out there.

hth,
Wayne
 
Hum... I did not realize all of that.

I guess I can just get by with putting the error number in the msgbox. I'd just like to know if the error is one of a handfull which would give me a pretty good idea where the problem may be...

Thanks for the info & code.
ken
 

Users who are viewing this thread

Back
Top Bottom