PRB: Datacombo Returns -2147217848 (80040e4e) Change CanceledID: Q229272
|
When using a DataCombo control, if the DataField property of the DataCombo is bound to a numeric data type a problem may occur under the following circumstances:
The user clicks the combo box and moves the mouse over the entries in the drop-down portion of the combo box but does NOT choose an item from the list. The user then clicks another control so that the DataCombo loses focus and an attempt is made to update the underlying data source specified in the DataField property.This action fails because the Text property of the combo is an empty string (non-numeric) and the bound field is a numeric type. In this case the following error message is returned:
-2147217848 (80040e4e) The change was canceled during notification; no columns are changed.
To work around this error check the Text property of the Datacombo. If it is blank, cancel the update to the underlying records. This work around is demonstrated in the code sample in the MORE INFORMATION section.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.
The following steps will reproduce this problem:
Private rsRowsource As ADODB.Recordset
Private rsDataSource As ADODB.Recordset
Private Sub DataCombo1_Validate(Cancel As Boolean)
On Error Resume Next
' Uncomment this code as a workaround
'---------------------------------------
' If DataCombo1.Text = "" Then
' rsDataSource.Cancel
' rsDataSource.Move 0
' Exit Sub
'
' End If
rsDataSource.Move 0
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
Private Sub Form_Load()
Set rsRowsource = New ADODB.Recordset
rsRowsource.Fields.Append "ID", adInteger
rsRowsource.Fields.Append "Descr", adVarWChar, 255
rsRowsource.Open
For x = 1 To 5
rsRowsource.AddNew Array("ID", "Descr"), Array(x, "Descr" & Str(x))
Next x
Set rsDataSource = New ADODB.Recordset
rsDataSource.Fields.Append "ID", adInteger
rsDataSource.Fields.Append "Foreign_ID", adInteger
rsDataSource.Open
DataCombo1.ListField = rsRowsource(1).Name
DataCombo1.DataField = rsDataSource(1).Name
DataCombo1.BoundColumn = rsDataSource(0).Name
Set DataCombo1.RowSource = rsRowsource
Set DataCombo1.DataSource = rsDataSource
rsDataSource.AddNew
End Sub
For more information on the DataCombo control, please see the Visual Basic 6.0 On-line help.
Additional query words: datacombo dropdown
Keywords : kbCtrl kbVBp600 kbGrpVBDB kbGrpMDAC
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 27, 1999