Adding dbFailOnError to CurrentDb.Execute fails to update table

为君一笑 提交于 2021-01-04 09:16:12

问题


Long time lurker, first time poster.

I have a mySQL table connected to Access 2010 via the 5.1 ODBC driver. I am trying to update the mySQL table and curiously adding dbFailOnError at the end of CurrentDb.Execute strSQL prevents the table from updating but does not throw any error. My VBA editor is set to break on all errors. All error handling in the routine has been commented for testing.

If I use CurrentDb.Execute strSQL or DoCmd.RunSQL strSQL, the table updates. Also, the mySQL table has an index.

SQL string:

strSQL = "UPDATE clients
SET [DateLastAccessed] = " & lngDateAccessed & ",
[CountAccess] = " & intCountAccessed & "
WHERE [SerialHDD] = '" & strGetHDD & "' ;"

Any help is much appreciated.


回答1:


"adding dbFailOnError at the end of CurrentDb.Execute strSQL prevents the table from updating but does not throw any error"

That could fail to update without a visible error if SetWarnings has been switched off. Check whether you get a different outcome when switching SetWarnings on immediately before executing the update statement.

DoCmd.SetWarnings True
CurrentDb.Execute strSQL, dbFailOnError 


来源:https://stackoverflow.com/questions/13943753/adding-dbfailonerror-to-currentdb-execute-fails-to-update-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!