SYMPTOMS
When you use the ActiveX Data Object (ADO) Data Control with a text box that is bound to certain data types, such as
Integer or
Date, you receive the following error message:
Operation was canceled.
The error message occurs when you move to a different record or update the record.
RESOLUTION
The following code demonstrates a workaround for the problem. In the
WillMove event of the ADO Data Control, set the
DataChanged property of the text box to
False, and then assign the value
NULL to the field:
Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If txtIntegerField.Text = "" Then
If txtIntegerField.DataChanged Then
txtIntegerField.DataChanged = False
Adodc1.Recordset.Fields("IntegerField") = Null
End If
End If
End Sub