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
Create new Standard EXE project. Form1 is created by default.
From the Project menu, click Components, select the Data Bound List Controls 6.0 check box, and then click OK.
Add a Databound combo, DBCombo1, to Form1.
Add two TextBox controls, Text1 and Text2.
Add a Data control, Data1.
Configure the property settings of these controls as follows:
Data1 - Data control DatabaseName = Biblio.mdb RowSource = Authors ReadOnly = True
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
Run the project, and type a name that matches an entry in the bound DBCombo control (such as Curry, Dave).
Press ENTER. Notice that the DBCombo1.SelectedItem property is not updated.
Clear the text in DBCombo, and type a name that matches an entry in the list (such as Wellin, Paul).
Press the UP ARROW or DOWN ARROW key. Notice that DBCombo1.SelectedItem is updated with the bookmark for "Wellin, Paul".