I am transitioning us from an MS Access 2007 backend to a SQL Server 2014 backend.
When I try to do a pass through insert I don't get the full SQL Server error message.
Dim qd As QueryDef
Dim rs As DAO.Recordset
On Error GoTo save_err
Set qd = CurrentDb.CreateQueryDef("")
qd.ReturnsRecords = False
If IsNull(Me.txtCategoryName) Then
MsgBox "enter a category name"
Else
qd.Connect = ConStringName
qd.sql = "INSERT INTO [Categories] (name) VALUES ('" & Text Field & "')"
qd.Execute
End If
In my test case, a unique constraint should raise an error that the name is duplicate and can't be inserted. Instead I just get an ODBC -- Call Failed.
If I instead try to create the pass through query in an actual query window, I get the full error.
My current error handler is a message box:
MsgBox "FormName|SubName: " & Error$, vbCritical, "Error"
If I switch the table to a linked table, and try to insert, there is no error raised. I want an error in this case.
How do I get the full error in VBA?