Microsoft KB Archive/140309

= BUG: Recordset Update Error Differs Between 16-Bit and 32-Bit =

Article ID: 140309

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q140309



SYMPTOMS
When running Update method on a recordset, the error message displayed for 16-bit Visual Basic and 32-bit Visual Basic are completely different. However, the cause of the error is the same. You didn't use the AddNew or Edit method before trying to save changes to a record.

16-Bit Error
Run-time error '3426':

The action was canceled by an associated object.

32-Bit Error
Run-time error '3020':

Update or CancelUpdate without AddNew or Edit.



CAUSE
The 16-bit error message is actually a Jet version 2.5 error message.



WORKAROUND
To workaround this bug, use the Edit method before the Update method, prior to saving the changes to a recordset, as shown below: Data1.RecordSet.Edit Data1.RecordSet.Update



STATUS
Microsoft has confirmed this to be a bug in the 16-bit version of Visual Basic 4.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce the Error in Visual Basic 4.0 16-Bit
 Start 16-bit Visual Basic 4.0, or if it is already running, click New Project on the File menu. Place a Data control on the Form1 form. Set the Data control's DatabaseName property to Biblio.mdb. Set the Data control's RecordSource property to Authors. Add a TextBox control to the Form1 form. First set the TextBox control's DataSource property to Data1 and then set the DataField property to Authors.</li> Add a command button to the Form1 form.</li>  Copy the following code sample to the Form1 code window: Private Sub Command1_Click 'To prevent the bug, uncomment the next line 'Data1.RecordSet.Edit Data1.RecordSet.Update End Sub </li> Press the F5 key or click Start on the Run menu to start the program.</li> Enter some text in the text box.</li> Click the command button. The following error message appears in the Microsoft Visual Basic Dialog Box:

Run-time error '3426':

The action was canceled by an associated object.

Click the End button to close the dialog box and end the program.</li> Save the project. The project can be used to re-create the 32-bit error.</li></ol>

Steps to Reproduce the Error in Visual Basic 4.0 32-Bit
<ol> Start 32-bit Visual Basic 4.0 or if it is already running, click Open Project on the File menu.</li> Open the project that you just saved in step 12 above.</li> Press the F5 key or click Start on the Run menu to start the program.</li> Enter some text in the text box.</li> Click the command button. The following error message appears in the Microsoft Visual Basic dialog box:

Run-time error '3020':

Update or CancelUpdate without AddNew or Edit.

Click the end button to close the dialog box and end the program.</li></ol>

<div class="references_section">