Microsoft KB Archive/179616

= PRB: Rollback Causes DAO Recordset Editmode To Be Set Back to 0 =

Article ID: 179616

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q179616



SYMPTOMS
If the edit command is issued for a recordset, and an unrelated transaction is rolled back before the update command, the following error is returned when the update command is issued:

run-time Error 3020 -- "Update or CancelUpdate Without Addnew or Edit"

If the transaction is committed, this error does not occur.



RESOLUTION
To work around this problem, move the rs.Update method statement so that it is executed before the transaction is started, as shown in the MORE INFORMATION section below. To implement this workaround, change the code that has two update commands, one of which is commented. Uncomment that one and comment the one that is not commented.



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
 Start a new Standard Exe VB project. Form1 is created by default. Check the reference to the DAO 3.5 object library. Add a new form, and then add a CommandButton to the form. Paste the code below into the CommandButton Click event.  Change the OpenDatabase method so that it points to the Northwinds database on your local machine, and then run the project: Private Sub Command1_Click

Dim rs As Recordset Dim db As Database

Set db = OpenDatabase("c:\mikework\dbs\nwind.mdb", 0, False, "")

Set rs = db.OpenRecordset("SELECT ContactName FROM Customers", _      dbOpenDynaset, 0, dbPessimistic)

rs.Edit    'This sets the editmode to 1. rs!ContactName = rs!ContactName & "H" Debug.Print rs.EditMode 'This will be 1. 'rs.Update  'Uncomment this line for workaround.

'Start the transaction. BeginTrans 'The processing that occurs in this transaction is unrelated 'to the above recordset. Rollback

Debug.Print rs.EditMode 'Editmode is now 0. rs.Update '<</ol>

Additional query words: kbVBp500 kbdse kbDSupport kbVBp kbDAO

Keywords: kbprb KB179616

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.