ACC2: Trapping Specific ODBC Error Messages

ID: Q129165


The information in this article applies to:


SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article demonstrates how to create a sample user-defined Access Basic function you can use to trap and parse a specific Open Database Connectivity (ODBC) error message, such as the error message returned by Microsoft SQL Server if you duplicate a unique index.


MORE INFORMATION

ODBC error strings are returned in two parts. The first part is the generic "ODBC call failed" error message; the second part is the specific error message. If you use the Err() function to trap only the error number (which is 3146 for a duplicate unique index), you trap only the first part, the generic "ODBC call failed" error message. To get the specific error message, you must parse the full error string that is returned.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Access Basic, please refer to the "Building Applications" manual.

Creating the Sample Function

To create the function that traps the specific error message, create a new module and enter the following procedure.

NOTES:


REFERENCES

Microsoft Access "Building Applications," version 2.0, Chapter 10, "Handling Run-Time Errors," pages 221-238


Keywords          : kbusage OdbcSqlms 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: April 9, 1999