Click here to Skip to main content
15,845,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to load the data from access to combo box with below code but I want to add only unique data (no duplicates ) in combo box. I am using DAO connection.

VB
mySet.MoveFirst
While Not mySet.EOF
    Combo1.List(I) = mySet.Fields(0)
    mySet.MoveNext
    I = I + 1
Wend
Posted
Updated 4-Jun-15 21:44pm
v2

1 solution

Since you are using a database then makes sense to modify your query in order to produce only unique values.
If the above option is not feasible then, before adding a new item, you may check if there is already an item with the same text in the ComboBox.
A third option would be adding all the items, sorting them and the traversing the ComboBox removing adjacent items having the same text.
 
Share this answer
 
Comments
Gaus Shaikh 5-Jun-15 3:36am    
Can you please provide me the coding in VB6
Gaus Shaikh 5-Jun-15 3:36am    
for last option

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900