Microsoft KB Archive/176873

= BUG: DBCombo Does Not Display the "&" Character Correctly =

Article ID: 176873

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q176873



SYMPTOMS
If a DBCombo control contains items with the ampersand (&) character as part of the text and if the style of the DBCombo control is dbcDropdownList, then the text will not display correctly in the text box portion (the edit area) of the control. The drop-down list area is not affected.

This problem does not occur with the styles dbcDropdownCombo or dbcSimpleCombo.



RESOLUTION
To work around this problem, simply modify the text to include an extra "&" for every "&" that is in the original text as shown in the following code: Private Sub DBCombo1_Click(Area As Integer) Dim i As Integer Dim s As String Dim c As String * 1

If DBCombo1.Style = dbcDropdownList And Area = dbcAreaList Then s = DBCombo1.Text If InStr(s, "&") Then DBCombo1.Text = "" For i = 1 To Len(s) c = Mid$(s, i, 1) If c = "&" Then DBCombo1.Text = DBCombo1.Text & "&&" Else DBCombo1.Text = DBCombo1.Text & c                  End If               Next End If      End If

End Sub



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
 Create a sample MDB (db1.mdb) and add one table (Table1) with one text field (Field1). Add the record "&one &&two &&&three" to Table1. Start Visual Basic and create a new Standard EXE. Form1 is created by default.  Add a Data control to Form1 and set the following properties: DatabaseName = "db1.mdb" RecordSource = "Table1"   Add a DBCombo control to Form1 and set the following properties: RowSource = "Data1" ListField = "Field1" Style = "2 - dbcDropdownList"  Run the project. Click the button on DBCombo1 and select the item from the list.</li></ol>

Keywords: kbbug KB176873

-

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

© Microsoft Corporation. All rights reserved.