Click to See Complete Forum and Search --> : how to bound combobox ?
kindjal
February 16th, 2000, 05:35 AM
hello,
i am having difficulties in bounding a field to a combo box. i use ado to connect to the database and get what i want into a recordset.
then i set the recordset as the record source of the combo box but all i get in return is that it displays only the first record.
can someone help me to populate this combo box ?
Johnny101
February 16th, 2000, 03:48 PM
I haven't been able to bind a combo box to a recordset and have the combo box populate, I always have to do it manually. Ie...
Function FillComboBox(cboMain as ComboBox, rs as ADODB.Recordset, sFieldName as string) as Boolean
on error Goto ErrorHandler
While Not rs.EOF
cboMain.AddItem rs(sFieldName)
rs.MoveNext
Wend
FillComboBox = true
Exit Function
ErrorHandler:
MsgBox error
End Function
You can call this function and just pass it your combo box contro, the recordset and the name of the field to put into the combo box and it will do it for you.
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
kindjal
February 16th, 2000, 04:00 PM
thanks for the reply
by the way, that's actually what i do for the moment as i can't still find out how to do it automatically ;)
d.paulson
February 17th, 2000, 08:45 PM
I am not sure of prior versions of vb but with vb6 there is a datacombo control, simular to the combobox, that can be bound to the database.
d.paulson
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.