In the same manner we can intercept certain error numbers for VBA errors we can do the same for ADO "data" errors. The trick is finding a list of the numbers. MS KB article Q168354 ("INFO: Underlying OLE and OLEDB Provider Errors Exposed via ADO") provides one great place to look. The sample code below illustrates:
Private Sub EnvironmentErr(ByRef DataErr As ADODB.Error, _
Optional ByVal ObjName = vbNullString)
Select Case DataErr.Number
Case -2147217900
p_strErrMsg = "ADO Environment Error: " _
& "An Object associated with """ _
& ObjName & """ was not found."
Case -2147467259
p_strErrMsg = "ADO Environment Error: " _
& "Connection to Data Source """ _
& pADOcnn.Properties("Data Source") _
& """ failed." & vbCrLf _
& "The specified Catalog """ _
& pADOcnn.Properties("Initial Catalog") _
& """ was not found."
Case Else
p_strErrMsg = "ADO Environment Error: " _
& DataErr.Number & ": " & DataErr.Description
End Select
End Sub