View Full Version : VB6 Help pls...
arian29
16-08-2008, 10:09 PM
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
17-08-2008, 07:37 AM
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.
.................................................. .............................................
dheeraj_kumar
17-08-2008, 09:51 AM
^^ Amir, next time, post with the source please.
Source: http://www.experts-exchange.com/Programming/Q_21568679.html
javed4shab
01-09-2008, 04:00 PM
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
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.