Not getting error msg on failed insert query

expat1000

Registered User.
Local time
Yesterday, 20:25
Joined
Apr 6, 2012
Messages
18
Access FE, SQL Server BE. I run a simple insert query in Access in the GUI. A no dup index on two fields in the table rejects it with an error message as it should. However
Code:
Set qry = CurrentDb.QueryDefs("query2")
qry.Execute dbSeeChanges

also fails but without an error being displayed so I can't trap it. Same goes for CurrentDb.Execute sSQL, dbSeeChanges I have preceded that statement with docmd.setwarnings(true). Is this expected behaviour?
 
maybe:

qry.Execute dbFailOnError
 
maybe:

qry.Execute dbFailOnError
I think the dbSeeChanges is required. This gives me argument error
Code:
qry.Execute dbSeeChanges, dbFailOnError
 
it's because it only accepts 1 argument:

qry.Execute dbSeeChanges + dbFailOnError
 
OK. That's got it - sort of. I get a generic error "ODBC--call failed" - better than nothing! Thank you.
 
OK. That's got it - sort of. I get a generic error "ODBC--call failed" - better than nothing! Thank you.

Something that would be PRICELESS for Microsoft to solution....getting actual SQL Server error messages back to Access.

I've put significant time into this issue and concluded that the closest an Access/T-SQL developer can come who wants to create server-side error handling with Access FE-side knowledge of it is a stored proc
How to capture SQL Server error via MS Access, after error not generated by DAO VBA code (microsoft.com)
 
Apparently there IS a way to get back an ODBC detailed code.



You get back some indication of an error from the basic call, so you call SQLGetDiagRec (get diagnostic record) to find out what went wrong.
 
Apparently there IS a way to get back an ODBC detailed code.



You get back some indication of an error from the basic call, so you call SQLGetDiagRec (get diagnostic record) to find out what went wrong.

Let me know if you know how to make Access use SQLFetch odbc.

Note in the post I linked to, the great need is to return errors when executing a saved query....not just when using an ado/dao connection
 

Users who are viewing this thread

Back
Top Bottom