Load data from access to combo box in vb

Solved/Closed
sophisticated19 - Aug 19, 2010 at 04:08 AM
 ian_ian - Jan 19, 2012 at 09:48 PM
Hello,

i'm really desperate for a solution here

can anybody please please tell me how to load data that i've stored in my access database into a combo box?

thank you in advance!


3 responses

dhanakumar(dk)
Aug 27, 2010 at 02:20 AM
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
Dim I As Integer
con.Open "Provider=sqloledb;Data Source=SSST41;Initial Catalog=sample;User ID=sa;Password=;"
str = "select name from stutable"
rs.Open str, con
i = 0

While Not rs.EOF
Combo1.List(i) = rs.Fields(0)
rs.MoveNext
i = I + 1
Wend

rs.Close
11
thank you for the code.. it works with my own way of connecting to Access...
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Aug 20, 2010 at 09:55 AM
Where is this combobox ? is it on access form or some thing else
1
sophisticated19
Aug 20, 2010 at 10:20 AM
the combo box is in a form created in a vb(2008) project...i have already connected the vb project to the access db. however, now i'm trying to figure out how to retrieve the information i've stored in the access field to the combo box created earlier.

tq!
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Aug 20, 2010 at 10:47 AM
It has been some time since I have played with VB. But from what I recall, you could set it record source to a sql statement.
0
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Dim I As Integer
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Asm-isntc-asus\database\mast.mdb;Persist Security Info=False"
str = "select Name from mast"
rs.Open str, con
i = 0

While Not rs.EOF
Combo3.List(i) = rs.Fields(0)
rs.MoveNext
i = I + 1
Wend

rs.Close
0
sophisticated19
Aug 20, 2010 at 10:19 AM
the combo box is in a form created in a vb(2008) project...i have already connected the vb project to the access db. however, now i'm trying to figure out how to retrieve the information i've stored in vb to the combo box created earlier.

tq!
0