Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how can i avoid duplication in combo box my code is given below
VB
rs1.MoveFirst
Do While Not rs1.EOF

Combo2.AddItem rs1.Fields("name")
rs1.MoveNext
Loop
End If
Posted
Updated 12-Jan-12 19:35pm
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-12 2:30am    
First thing to think about is this: why do you have duplicate items in first place?
--SA

1 solution

'You must test before add item

rs1.MoveFirst
Do While Not rs1.EOF

If Not Me.Combo2.Items.Contains(rs1.Fields("name")) Then
Me.Combo2.Items.Add(rs1.Fields("name"))
End If

rs1.MoveNext
Loop
 
Share this answer
 
Comments
zakariyaptpl 13-Jan-12 14:54pm    
thx

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