|
-
July 19th, 2000, 10:11 AM
#1
Populate Combo Box from a recorset
I want to populate a Combo Box from a recordset (I want to list every values of a column).
Thanks ! :-)
-
July 19th, 2000, 10:18 AM
#2
Re: Populate Combo Box from a recorset
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
-
July 20th, 2000, 02:16 AM
#3
Re: Populate Combo Box from a recorset
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
-
July 20th, 2000, 02:41 AM
#4
Re: Populate Combo Box from a recorset
I think this chech <> "" is not apropriate.
Take a look at the IsNull() function.
-
July 20th, 2000, 02:48 AM
#5
Re: Populate Combo Box from a recorset
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|