martes, 11 de junio de 2013

Run-time error 3146 ODBC--cal failed

¿Qué hacer si aparece el error Run-time error 3146 ODBC--cal failed?

1) Creamos una función como la siguiente:

Function TestODBCErr()
If Errors.Count > 1 Then
For Each errX In DAO.Errors
Debug.Print "ODBC Error"
Debug.Print errX.Number
Debug.Print errX.Description
Next errX
Else
Debug.Print "VBA Error"
Debug.Print Err.Number
Debug.Print Err.Description
End If
End Function

Fuente: http://www.utteraccess.com/forum/Runtime-Error-3146-t1993453.html&p=2285193

2) Insertamos esa función desde el menú Insert / Module del editor de VBA

3) Ejecutamos el programa hasta que aparezca el error y presionamos DEBUG

4) Abrimos una ventana Immediate Window con Ctrl+G o desde el menú View

5) Insertamos el código ? TestODBCErr() y presionamos enter

6) Luego obtenemos un mensaje detallado que varía de acuerdo a nuestro problema específico. Un ejemplo es:

ODBC Error
 2601 
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert duplicate key row in object 'dbo.Contactos' with unique index 'IX_Contactos'.
ODBC Error
 3621 
[Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated.
ODBC Error
 3146 
ODBC--call failed.

Espero les resulte útil!