DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   FILL COMBO WITHOUT dupes... (http://www.daniweb.com/forums/thread166753.html)

sal21 Jan 7th, 2009 8:05 am
FILL COMBO WITHOUT dupes...
 
Admit have mymdb.mdb with table mytable and filed myfield in c:\...
Ho to fill combobox without dupes from table, please without "select distinct..." statement is possible?
Tks.

selvaganapathy Jan 7th, 2009 11:41 am
Re: FILL COMBO WITHOUT dupes...
 
Hi,
My suggestion
> Use ORDER BY Clause
> Iterate thru all records
> If duplicate occurs (If current = previous), simply ignores it

QVeen72 Jan 8th, 2009 12:08 am
Re: FILL COMBO WITHOUT dupes...
 
Hi,

Try This :

Code is easy for ListBox..
If you want To Poulate a Combo Only, Then Place a ListBox on the Form and Set it's property Visible = False

Dim str1 As String
RS.MoveFirst
List1.Clear
Combo1.Clear
Do While Not RS.EOF
    str1 = RS("MyField") & ""
    List1.Text = str1
    If List1.SelCount = 0 Then
      List1.AddItem str1
      Combo1.AddItem str1
    End If
    RS.MoveNext
Loop

Regards
Veena


All times are GMT -4. The time now is 3:18 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC