LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Populating a multi column listbox with ADO Recordset

I'm trying to populate a multi column listbox with a ADO recordset I have
retrieved from Access, the code I have so far is adapted from the Microsoft
site and works fine for a single column, but I cannot get the Age records to
show, can anybody help?

The code so far;


Public Sub PopulateControl()

Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String

strSQL = "SELECT Name, Age FROM [table];"
Set cnt = New ADODB.Connection
With cnt
..Provider = "Microsoft.Jet.OLEDB.4.0"
..Properties("Data Source") = "F:\TESTADO.mdb"
'.Properties("Jet OLEDB:Database Password") = "REDUNDANT"
..Open
End With

Set rst = New ADODB.Recordset
With rst
..CursorType = adOpenKeyset
..LockType = adLockOptimistic
..Open strSQL, cnt
End With

' Moves to the first record in the record set.
rst.MoveFirst

Do Until rst.EOF
UserForm1.ListBox1.AddItem rst!Name
rst.MoveNext
Loop

UserForm1.Show

rst.Close
cnt.Close

End Sub

thanks,
Paul
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating Column Headers in a ListBox KL[_4_] Excel Programming 4 September 1st 04 12:55 PM
filling a two column listbox from a two column recordset Dennis Excel Programming 5 May 23rd 04 10:13 PM
How to populate a multi-column activeX listbox on a spreadsheet with an ADO recordset quartz Excel Programming 1 May 3rd 04 10:13 PM
populating a multi-column Listbox Tom Ogilvy Excel Programming 3 April 26th 04 08:26 PM
populating a multi-column Listbox Harald Staff Excel Programming 1 April 26th 04 08:26 PM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"