BUG: DBCombo SelectedItem Property Is Not Updated When You Type Selection

This article was previously published under Q281940
This article has been archived. It is offered "as is" and will no longer be updated.
When you use the type-ahead searching features of the DBCombo control from DBList32.ocx, the SelectedItem property is not updated, and DBCombo does not reflect the matching entry that is found.
A supported fix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Apply it only to computers that are experiencing this specific problem. This fix may receive additional testing. Therefore, if you are not severely affected by this problem, Microsoft recommends that you wait for the next Visual Studio service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

NOTE: You must have a Visual Studio license agreement to obtain this fix.

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
When you select an item in the list portion of a DBCombo control, the SelectedItem property contains a bookmark that you can use to reposition the selected record in the Recordset of the Data control that the RowSource property specifies. This property should be updated whether the user uses a mouse or the keyboard to select the item. Thus, when you use the type-ahead searching feature of this control, you expect that the SelectedItem property is updated after you type a name that matches a name in the list and press the ENTER key. In addition, the text in DBCombo should reflect the matching entry that is found. However, this functionality does not work when you use the standard Databound Combo and the Intrinsic Data control that shipped with Visual Basic 6.0.

Steps to Reproduce Behavior

  1. Create new Standard EXE project. Form1 is created by default.
  2. From the Project menu, click Components, select the Data Bound List Controls 6.0 check box, and then click OK.
  3. Add a Databound combo, DBCombo1, to Form1.
  4. Add two TextBox controls, Text1 and Text2.
  5. Add a Data control, Data1.
  6. Configure the property settings of these controls as follows:
    Data1 - Data control
    DatabaseName = Biblio.mdb
    RowSource = Authors
    ReadOnly = True

    Text2 - TextBox control
    DataSource = Data1
    DataField = Author
    Visible = False

    DBCombo1 - Databound Combo control
    RowSource = Data1
    ListField = Author
  7. Add the following code to the General Declarations section of Form1:
    Option ExplicitPrivate Const UP_ARROW = 38Private Const DOWN_ARROW = 40    Private Sub Data1_Reposition()   '   ' Copy Text from Bound Text2 to Unbound Text1.   Text1.Text = Text2.TextEnd Sub    Private Sub DBCombo1_KeyUp(KeyCode As Integer, Shift As Integer)   Dim bmk As Variant   Dim x As Integer   Dim msg As String   On Error GoTo ErrHandler   '   ' Save Bookmark on CR and Arrow Key Activity.   Select Case KeyCode      Case Asc(vbCr), UP_ARROW, DOWN_ARROW          msg = "DBCombo1.SelectedItem has the value "          bmk = DBCombo1.SelectedItem          ' The next line raises error 13 if bmk has no value.          For x = 0 To UBound(bmk)              msg = msg & bmk(x)          Next x          Data1.Recordset.Bookmark = bmk          Debug.Print msg   End Select   Exit Sub            ErrHandler:   If Err.Number = 13 Then   ' Type mismatch      Debug.Print "DBCombo1.SelectedItem is not assigned a value."   Else      MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical _         + vbOKOnly   End IfEnd SubPrivate Sub Form_Load()   Text1.Text = ""   DBCombo1.Text = ""End Sub					
  8. Run the project, and type a name that matches an entry in the bound DBCombo control (such as Curry, Dave).
  9. Press ENTER. Notice that the DBCombo1.SelectedItem property is not updated.
  10. Clear the text in DBCombo, and type a name that matches an entry in the list (such as Wellin, Paul).
  11. Press the UP ARROW or DOWN ARROW key. Notice that DBCombo1.SelectedItem is updated with the bookmark for "Wellin, Paul".

Article ID: 281940 - Last Review: 02/28/2014 04:23:58 - Revision: 3.2

  • Microsoft Visual Basic 6.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • kbnosurvey kbarchive kbbug kbcodesnippet kbprb kbctrl kbpending KB281940