I want to control the error message(s) which are received when/if an error is thrown when trying to connect to an external table in a SQL database. I have some code which refreshes the link to any/all linked tables. It works great. The user could muck it up by accidently typing the SQL server location incorrectly or entering a username password combination which is incorrect or which does not have the rights needed to view the data. In any of those cases, a large error message appears which goes something like (ignore typos as I used OCR to change a screen grab into text):
In the function which refreshes the links, I have the following code to handle errors:
I want better control of the error message which appears when it encounters an ODBC error. If this question is too complex to address in this setting, please refer me to a book which teaches how to do it. Thank you.
MrsBean
Code:
Connection failed:
SQLState: 01S00
SQL Server Error: 0
[Microsoft][ODBC SQL Server Driver]lnvalid connection string attribute Connection failed:
SQLState: 01000
SQL Server Error: 53
[Microsoft]IODBC SQL Server Driver ][DBNE TLIB]ConnectionO pen (Connect(fl. Connection failed:
SQLState: 08001’
SQL Server Error 17
[Microsoftl(DDBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
In the function which refreshes the links, I have the following code to handle errors:
Code:
ErrorHandlerExit:
Exit Function
ErrorHandler:
MsgBox Err.Number & " : " & Err.Description, vbExclamation, "ODBC Error"
Resume ErrorHandlerExit
I want better control of the error message which appears when it encounters an ODBC error. If this question is too complex to address in this setting, please refer me to a book which teaches how to do it. Thank you.
MrsBean