Germain Yann
July 19th, 2000, 10:11 AM
I want to populate a Combo Box from a recordset (I want to list every values of a column).
Thanks ! :-)
Thanks ! :-)
|
Click to See Complete Forum and Search --> : Populate Combo Box from a recorset Germain Yann July 19th, 2000, 10:11 AM I want to populate a Combo Box from a recordset (I want to list every values of a column). Thanks ! :-) TH1 July 19th, 2000, 10:18 AM If your recordset is called rs and the field in the database that you want in the combo box is field1 then once you have opened the recordset do until rs.eof Combo1.Additem rs!field1 rs.Movenext loop Germain Yann July 20th, 2000, 02:16 AM Real thanks. There was a problem if thfield is null,to correct that you just have to make this test in the loop: If recordset.field <>" " then ...... End If vin July 20th, 2000, 02:41 AM I think this chech <> "" is not apropriate. Take a look at the IsNull() function. vin July 20th, 2000, 02:48 AM Hi, The most straightforward way, apparently is to read one by one the records from the recordset and to add them to the list/combo box. This, however, is a little awkward approach, because with larger databases the time to load the control will be really long. As the smart people know that we will encounter such problems, they have made databound controls that can be linked to the recordset. They work really fast. You may wish to search a little about this databound controls in the MSDN. If you do not want to "waste" your time searching for these databound controls you can do a thing to speed up your loading process. Before starting the loop that fills the combo/list box one by one just make this combo/list box unvisible i.e. set its visible propery to false. This will speed up the process considerably. Regards, Valery Nikolov http://listen.to/quark codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |