VB6 Help pls...

Status
Not open for further replies.

arian29

In the zone
How to connect a list box to a access database so that the list is populated with the data in the access table for VB6 ? :confused:
 

Amir.php

Flying Visitor
Create a form with list box
Create reference to database [ msado25.dll ] or you can use any version.

Dim objCnn As New ADODB.Connection
Dim objRss As New ADODB.Recordset
Private Sub Form_Load()

objCnn.ConnectionString = "Provide your connection string here"
objCnn.Open

Set objRss = objCnn.Execute("Select <fieldName> from <tablename>")
Do While Not objRss.EOF
lstUsers.AddItem objRss.Fields(0).Value
objRss.MoveNext
Loop

This will populate the list box with values.

In design mode itself you can set the Style property of the list box to 1-Checkbox
Or through code you can do like lstUsers.Style = 1.
...............................................................................................
 
Last edited:

dheeraj_kumar

Legen-wait for it-dary!
^^ Amir, next time, post with the source please.

Source: *www.experts-exchange.com/Programming/Q_21568679.html
 
J

javed4shab

Guest
Boss,
You can Use "Data List" or "Data COmbo" boxes. These are available in "VB Enterprise Edition Controls."
and set properties :
datasource = adodc1
rowsource = adodc1
listfield = "name of field which you want to add to list"
Works best for want you want.

Enjoy :p
 
Status
Not open for further replies.
Top Bottom