![]() |
Filling a listbox
Hi,
I have added a multi-column ListBox to a user form and need to fill it with data using VBA/ADO the data is retrieved into a recordset from SQL Server using this statement: rst.open "select Id, Name, Address1 from Customers where name like 'abc%'", oconn I am looking for something like lstCustomers.rowsource = rst, which does not work here Thanks in advance for your suggestions. Regards Habib |
Filling a listbox - update
I filled the contents of the recordset into range and used
Me.lstCustomers.RowSource = ("A26:B" & 26 + rs.RecordCount) My listbox now has data. However, I do not see all the columns, the columns are too wide Me.lstCustomers.RowSource = ("A26:B" & 26 + rs.RecordCount) Me.lstCustomers.ColumnCount = 12 Me.lstCustomers.ColumnWidths = "60 pt;72 pt;72 pt;72 pt;72 pt;36 pt;36 pt;36 pt;36 pt;36 pt;36 pt; 36 pt" Me.lstCustomers.Width = 600 wht am I doing wrong? -- www.DynExtra.com A resource for the Microsoft Dynamics Community Featuring FAQs, File Exchange and more Current member count: 40 -------------------------------------------- Share your knowledge. Add your favorite questions and answers Help add questions to this site! We want Your input. -------------------------------------------- "HSalim[MVP]" wrote in message ... Hi, I have added a multi-column ListBox to a user form and need to fill it with data using VBA/ADO the data is retrieved into a recordset from SQL Server using this statement: rst.open "select Id, Name, Address1 from Customers where name like 'abc%'", oconn I am looking for something like lstCustomers.rowsource = rst, which does not work here Thanks in advance for your suggestions. Regards Habib |
All times are GMT +1. The time now is 04:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com