PRB: Error Message When You Save a NULL Value with ADODC and Bound Controls (286241)
The information in this article applies to:
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.5 SP1
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
This article was previously published under Q286241 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.
CAUSE
The data control is sending a NULL string to an ADO field that is defined as a number or other non-character field.
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
Modification Type: | Major | Last Reviewed: | 5/8/2003 |
---|
Keywords: | kbDatabase kbprb KB286241 |
---|
|