ACC: Update or Delete Query Fails Without Generating ErrorLast reviewed: May 14, 1997Article ID: Q117163 |
The information in this article applies to:
SYMPTOMSModerate: 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.
CAUSEThose 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.
RESOLUTIONIn 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 FunctionIn Microsoft Access version 1.x, create a dynaset in Access Basic code that includes all the records that should be modified. Within transactions (BeginTrans and CommitTrans), modify each record in the dynaset until all the records are updated. This technique will generate an error that you can trap if a locking conflict occurs. You can then issue a rollback on the transaction and try to update the record again until the update succeeds.
STATUSThis behavior no longer occurs in Microsoft Access version 7.0.
MORE INFORMATION
Steps to Reproduce Problem
|
Keywords : kbusage QryMktbl
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |