Microsoft KB Archive/281940

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

Article ID: 281940

Article Last Modified on 10/7/2005

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Learning Edition

-



This article was previously published under Q281940



SYMPTOMS
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.



RESOLUTION
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:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
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

Text2 - TextBox control

DataSource = Data1

DataField = Author

Visible = False

DBCombo1 - Databound Combo control

RowSource = Data1

ListField = Author

</li>  Add the following code to the General Declarations section of Form1: Option Explicit

Private Const UP_ARROW = 38 Private Const DOWN_ARROW = 40 Private Sub Data1_Reposition '  ' Copy Text from Bound Text2 to Unbound Text1. Text1.Text = Text2.Text End 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 = &quot;DBCombo1.SelectedItem has the value &quot; 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 &quot;DBCombo1.SelectedItem is not assigned a value.&quot; Else MsgBox &quot;Error &quot; & Err.Number & &quot;: &quot; & Err.Description, vbCritical _ + vbOKOnly End If End Sub

Private Sub Form_Load Text1.Text = &quot;&quot; DBCombo1.Text = &quot;&quot; End Sub </li> Run the project, and type a name that matches an entry in the bound DBCombo control (such as Curry, Dave ).</li> Press ENTER. Notice that the DBCombo1.SelectedItem property is not updated.</li> Clear the text in DBCombo, and type a name that matches an entry in the list (such as Wellin, Paul ).</li> Press the UP ARROW or DOWN ARROW key. Notice that DBCombo1.SelectedItem is updated with the bookmark for &quot;Wellin, Paul&quot;.</li></ol>

Keywords: kbbug kbcodesnippet kbprb kbctrl kbpending KB281940

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.