ACC: Update or Delete Query Fails Without Generating ErrorID: Q117163
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you run an update or delete query in code using the Execute
method, some records are not modified or deleted, and no error message is
generated.
Those records that were not modified or deleted were locked when the action query was run. A record is locked whenever it is being edited, whether that editing is done through the user interface, from code, or by an action query.
In Microsoft Access version 2.0, use the DB_FAILONERROR argument when you
use the Execute method to run an action query from code. This switch issues
a rollback and generates an error when locking conflicts occur, resulting
in the cancellation of all updates. The following is a code example showing
the use of the DB_FAILONERROR argument and error trapping:
Option Explicit
Function RunUDQuery ()
Dim db As Database, qdef As QueryDef
Set db = CurrentDB()
Set qdef = db.QueryDefs("UDQuery")
On Error GoTo Errorhandler
qdef.Execute DB_FAILONERROR
Exit Function
Errorhandler:
MsgBox "Update Failed " & Err & " " & Error
Exit Function
End Function
This behavior no longer occurs in Microsoft Access version 7.0.
Info
----
ddd
aaa
ccc
ddd
ddd
eee
Option Explicit 'If not already present.
Function RunUDQuery ()
Dim db As Database, qdef As QueryDef
Set db = CurrentDB()
Set qdef = db.OpenQueryDef("UDQuery")
qdef.Execute
End Function
Keywords : kbusage QryMktbl
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 6, 1999