PRB: CancelUpdate Does Not Cancel ActiveX Data Objects Update (270118)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q270118 SYMPTOMS
When the value of a bound TextBox control is set through code and calls the ActiveX Data Objects (ADO) CancelUpdate method, it does not cause the update to be cancelled (for example, the changes are reflected in the database).
CAUSE
This behavior occurs because when the TextBox control value is set through code, the actual update to the database does not occur until MoveNext is called for the ADO recordset that the TextBox is bound to. The CancelUpdate call has no effect because there is not an update that can be cancelled.
RESOLUTION
To cause an update to occur before the MoveNext call, add code to call the SetFocus method of the TextBox immediately after the line of code that updates its value. After you do this, the control goes through a validation process when it loses focus. The validate code that runs under the covers causes an update to occur and the CancelUpdate has the effect of canceling that update.
Modification Type: | Major | Last Reviewed: | 8/23/2001 |
---|
Keywords: | kbprb KB270118 |
---|
|