Access Error Codes

Status
Not open for further replies.

isladogs

MVP / VIP
Local time
Today, 15:50
Joined
Jan 14, 2017
Messages
18,547
The attached db contains details of all VBA errors as supplied by Microsoft

I compiled this list of Access VBA error codes whilst creating an error logging system for one of my databases.

Its also very useful as a reference e.g. when posters mention a particular error in their database.

I hope this is useful to others

attachment.php


A report is also available but its about 90 pages long so think before you print it!

Clicking the Search the Internet button runs a Google search for the selected error:

attachment.php


NOTE: If anyone has a full list of JET errors which can also arise occasionally, let me know and I'll add these to the database
Examples include error numbers -2147467259, -2147221233, -2147352567, -2147024894.
Apparently there is a way of converting these negative numbers into standard VBA error codes but I don't know how to do that

=======================================
UPDATE: 28/07/2017
I've just realised the report in v1 of this db threw up a parameter error.
Now fixed and I've updated the attached database to v2.
 

Attachments

  • AccessErrorCodes.PNG
    AccessErrorCodes.PNG
    19.1 KB · Views: 3,152
  • AccessErrorCodes v2.accdb
    AccessErrorCodes v2.accdb
    1.4 MB · Views: 704
  • ErrorGoogleSearch.PNG
    ErrorGoogleSearch.PNG
    72.5 KB · Views: 2,714
Last edited:
In response to a PM on this subject:

Take an error code such as -2147352567 and bring up the ubiquitous CALCULATOR. Switch it from "Standard" to "Programmer." Be sure you are in DECIMAL mode. Paste that number into the working area. Now switch mode to HEXADECIMAL. You will get FFFFFFFF80020009 and you can discard the 8 leading "F" characters. So now you have the string 80020009.

Looking up the HRESULT stuff ( https://msdn.microsoft.com/en-us/library/windows/desktop/ms690088(v=vs.85).aspx ) you see that this can be broken down as

First 4 bits: 0x8 - which means non-critical error. (The critical errors of the form 0xC are only seen on a BSD because they crash Windows).

Next 12 bits: 0x002 - which says iDispatch error. You have to look a bit for this one.

Next 16 bits: 0x0009 - which says ERROR_INVALID_BLOCK. (See also https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx for the list of low-numbered errors.) I'm not going to swear that I understand why you would get this error, but the last time I saw it, it was due to having the wrong type of variable in one of arguments of an automation call - using a Variant when the call specifically demanded a string.

Let's do another:

With the calculator, code -2147024894 resolves to FFFFFFFF80070002, or 0x8, 0x007, 0x0002. The same comments as above apply for 0x8. The 0x007 is a WIN32 error (or OLE error). Code 0x0002 is FILE_NOT_FOUND. This one speaks for itself.

Hope that helps.
 
Thanks Doc

I just found this helpful post at:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_access-mso_other/runtime-error-3376-vs-2147217865-80040e37/5e3aa627-277f-476a-b301-d79a4c09a73c

runtime error 3376 vs -2147217865 (80040e37)

Error codes are unsigned 32-bit numbers, which are represented in a linear fashion from 0 (no bits set) to hexadecimal FFFFFFFF (all bits set). This is a very large number - almost 4.3 billion.
In VBA there is no such data type, so error codes are treated as signed 32-bit numbers (Long). These numbers are represented in a circular fashion, from 0 to 7FFFFFFF (+2147483647) and then from 80000000 (-2147483648) to FFFFFFFF (-1).
So actually, half of all possible error codes are negative!
Different component libraries have different ranges of error codes. DAO has error codes ranging from 3000 to 3500, while ADO has error codes ranging from vbObjectError+3000 (decimal -2147218504) to vbObjectError+3800 (decimal -2147217704).

So the error you get from executing "DROP TABLE xxxx" depends on whether you execute it with DAO or ADO.
This will give you error 3376:
CurrentDb.Execute "DROP TABLE xxxx"
This will give you error -2147217865:
CurrentProject.Connection.Execute "DROP TABLE xxxx"
Both errors mean "Table does not exist"
 
Thanks again Doc for explaining how you do the conversions.
Its so long since I needed to do this that I had forgotten how.

As can happen with moderated areas, I didn't see your reply to my PM before I posted.

I hadn't realised that the negative error codes were ADO.

For info, if you type something like this into the immediate window
Code:
 err.raise -2147352567
the error message is displayed complete with the hexadecimal equivalent with the first 8 characters already discarded

All 4 ADO errors that I included in post 1 are described as automation errors.

If anyone has a ready made function to convert these numbers to hex equivalents, it would be appreciated to save me reinventing the wheel
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom