Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I used the code shown below to populate a combobox in a Word UserForm.
It basically cycles through each record and loads the value of field 1, 2 or 3 into the combobox depending on a user selection. Is there a way to use the combobox '.List" method to populate the list all at once vice cycling through each record. Something like: me.combobox.List = mySSRange Column 1 Thanks. Private Sub UserForm_Initialize() 'You need to set a reference in your project to the '"Microsoft DAO 3.51 (or 3.6) Object Library". Dim db As DAO.Database Dim rs As DAO.Recordset Dim i As Long 'Open a spreadsheet to retrieve data Set db = OpenDatabase("C:\Book1", False, False, "Excel 8.0") Set rs = db.OpenRecordset("SELECT * FROM `mySSRange`") i = 0 'Loop through each recordset. Me.ComboBox1.Clear While Not rs.EOF Select Case ActiveDocument.FormFields("Dropdown1").Result Case "A" Me.ComboBox1.AddItem rs.Fields(0).Value Case "B" Me.ComboBox1.AddItem rs.Fields(1).Value Case "C" Me.ComboBox1.AddItem rs.Fields(1).Value End Select rs.MoveNext i = i + 1 Wend 'Clean up. rs.Close db.Close Set rs = Nothing Set db = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populate ComboBox with Enum | Excel Programming | |||
use selected value from one combobox to populate another combobox | Excel Programming | |||
Populate combobox | Excel Programming | |||
Populate a combobox | Excel Programming |