Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo - remove duplicate values

Status
Not open for further replies.

murushanmugham

IS-IT--Management
Jan 2, 2003
33
Private Sub Command1_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset

With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\name.mdb"
.Open
End With

rs.Open "SELECT * FROM Users", conn, adOpenForwardOnly, adLockReadOnly

For i = 0 To rs.Fields.Count - 1
Combo1.AddItem rs.Fields(i).Name
Next

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing

MsgBox "Field names loaded!", vbInformation

End Sub

i want to remove the duplicate value , how i remove it

thanks in advance muru
 
okay
my main aim is to remove the combo box

that is repetative value may not add in the combo box

 
i mean

"Christ"
"King"
"Jesus"
"King"

that means automatically remove king from the combo list

muru

 
The reason peter does not quite understand you is because he's already given you a method for eliminating such duplications, and you have not explained why that suggestion is inappropriate for you (which makes it difficult to suggest alternatives)
 
ssql = "SELECT DISTINCT sname from libmas order by sname"
rs.Open ssql, con, adOpenKeyset, adLockOptimistic
Dim i As Long
For i = 0 To rs.RecordCount
Subject.AddItem rs("sname")
Next
distinct item in the list is 80

combo box add only first 80 records only, all are same name

muru
 
i made a mistake of rs.movenext

ok thank you very much

it works fine

muru
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top