|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Combo Boxes...Please Advice
if i have a combo box and it contains a records such as:
1 2 3 2 4 1 3 3 and i want to remove the records that are duplicated..since i am getting the records from Database i only want tha number to appear once.. How can i do this? i used this code but it doesn't work right. it keeps giving some similar records and sometimes elminates some records. May i have some help in this..thanx a lot in advance The Code is as follows: For i = 0 To cmbRecords.ListCount - 1 num = cmbRecords.List(i) For k = 1 To cmbRecords.ListCount - 1 If num = cmbRecords.List(k) Then cmbRecords.RemoveItem (k) End If Next k Next i where the cmbRecords is the combo box . Please help as soon as possible..Thanx again |
|
#2
|
|||
|
|||
|
How are you loading the combobox for the database?
|
|
#3
|
|||
|
|||
|
Hi,
I can explain why your code sometimes eliminates duplicate records and on other times eliminates normal records. When you remove an item, the whole list underneath that item moves up by 1. A common mistake when it comes to comboboxes. If you populate the combobox from a database, it is best to do a SELECT DISTINCT or SELECT DISTINCT ROW. The former and the later do the same, but not all SQL dialects understand both of them. Look in the reference for your SQL syntax to see which one you must use (or try them both and see what gives an error). If you got any questions, feel free to ask. Grtz.© M. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Combo Boxes...Please Advice |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|