General discussion

Locked

DataCombo

By setivi ·
How can I display two data fields or columns in the dropdown portion of a datacombo?
The listfield property seems to allow only one field.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

DataCombo

by sl-campbell In reply to DataCombo

As opposed to the MS Access DBCombo, the combo box delivered with VB6 does not automatically fill a list with more than one field. You have to do this manually.
What I do is get the fields from the recordset that I want to show in the combo and assign them to a variable. To do this you need to create a loop on the recordset in order to get the fields for all records:

Combo1.Clear

Do Until rsData.EOF

sListFld1 = rsData("myFirstField")
sListFld2 = rsData(("mySecondField")

Combo1.AddItem sListFld1 & vbTab & vbTab & sListFld2

Loop


There are other ways of doing this such as using a combo in conjunction with a list box and then hooking the list box up to the combo, where the list box is not visible and when the combo box isclicked, it doesn't drop down, but instead the list box becomes visible.

Collapse -

DataCombo

by sl-campbell In reply to DataCombo

Sorry, right after AddItem and before the Loop you need to add the following line:

rsData.MoveNext

And you may need to add MoveFirst after Combo1.Clear

Collapse -

DataCombo

by setivi In reply to DataCombo

answer shed some light on my difficulties. very helpful.

Collapse -

test

by sl-campbell In reply to DataCombo
Collapse -

DataCombo

by setivi In reply to DataCombo

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums