Microsoft KB Archive/269522

= BUG: Data in Bound Text Box Does Not Return to Original Value After CancelUpdate If Changed in Code =

Article ID: 269522

Article Last Modified on 5/8/2003

-

APPLIES TO

 Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Data Access Components 2.1

 Microsoft Data Access Components 2.1 Service Pack 2

 Microsoft Data Access Components 2.1 Service Pack 1

 Microsoft Data Access Components 2.1 Service Pack 2</li></ul>

 Microsoft Data Access Components 2.5</li></ul>

 Microsoft Data Access Components 2.6</li></ul>

 Microsoft Data Access Components 2.7</li></ul> </li> Microsoft Visual Basic 6.0 Enterprise Edition, when used with:  Microsoft Data Access Components 2.1</li></ul>

 Microsoft Data Access Components 2.1 Service Pack 2</li></ul>

 Microsoft Data Access Components 2.1 Service Pack 1</li></ul>

 Microsoft Data Access Components 2.1 Service Pack 2</li></ul>

 <li>Microsoft Data Access Components 2.5</li></ul>

<ul> <li>Microsoft Data Access Components 2.6</li></ul>

<ul> <li>Microsoft Data Access Components 2.7</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q269522

<div class="symptoms_section">

SYMPTOMS
When you update a bound text box by setting its text property in code, and then you call a CancelUpdate method, the value in the field does not revert to its original value.

<div class="resolution_section">

RESOLUTION
Instead of setting the text property of the bound text box, set the value of the underlying recordset field directly, as follows:

Adodc1.Recordset!LastName = &quot;Smith&quot;

The bound text box should update itself after you run the code. Subsequent calls to the CancelUpdate method then work as expected, and change the text box contents back to its original value.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> <li>Start a new Data Project in Microsoft Visual Basic. Form1 is created by default.</li> <li>From the Project menu, click Components, and then click Microsoft ADO Data Control from the list to load the ADO Data Control into the toolbox.</li> <li>Insert a Microsoft ActiveX Data Objects (ADO) data control, two text boxes, and two command buttons on to Form1.</li> <li> Set the ConnectionString property of the ADO Data Control to: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB </li> <li>Set the Caption property of the first command button to &quot;Copy&quot; and set the Caption property of the second command button to &quot;Cancel Update&quot;.</li> <li> In the Click event of the command button labeled &quot;Cancel Update&quot;, enter the following code: Adodc1.Recordset.CancelUpdate Adodc1.Recordset.MoveNext Adodc1.Recordset.MovePrevious </li> <li> In the Click event of the command button labeled &quot;Copy&quot;, enter the following code: Text1.Text = Text2.Text </li> <li> Set the Recordsource property of the ADO data control to: SELECT * FROM Employees </li> <li>Set the DataSource property of the Text1 text box to &quot;adodc1&quot;, and set the DataField property to &quot;LastName&quot;.</li> <li>Run the project. You should see &quot;Davolio&quot; display in the bound text box, and the text &quot;text2&quot; display in the unbound text box.</li> <li>Make a change to the name in Text1, and then click the Cancel command button. The name &quot;Davolio&quot; reappears in the bound text box.</li> <li>Click the Copy command button. The value in the bound text box changes to &quot;text2&quot;.</li> <li>Click the Cancel command button. Nothing happens. The value in the underlying recordset is permanently changed by the MoveNext method call and the update is not cancelled.</li></ol>

Keywords: kbbug kbpending KB269522

-

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

© Microsoft Corporation. All rights reserved.