Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to set the rowsource for a combo box from a table in a
database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub UserForm_Initialize()
Dim Recordset As ADODB.Recordset Dim SQL As String Set Recordset = New Recordset SQL = "SELECT * FROM returned" '<--- Change to match your table 'The SELECT * will return everything from 'the specified table. Recordset.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly 'open the recordset Do Until Recordset.EOF UserForm1.ComboBox1.AddItem (Recordset.Fields.Item(3)) Recordset.MoveNext Loop End Sub "Ken" wrote: I am trying to set the rowsource for a combo box from a table in a database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is really an Excel Programming group, but anyway....
Look here for a great video tutorial on this: http://datapigtechnologies.com/flash...combobox1.html When you've conquered that, learn these techniques: http://datapigtechnologies.com/flash...combobox2.html http://datapigtechnologies.com/flash...combobox3.html Regards, Ryan--- -- RyGuy "Jeff" wrote: Private Sub UserForm_Initialize() Dim Recordset As ADODB.Recordset Dim SQL As String Set Recordset = New Recordset SQL = "SELECT * FROM returned" '<--- Change to match your table 'The SELECT * will return everything from 'the specified table. Recordset.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly 'open the recordset Do Until Recordset.EOF UserForm1.ComboBox1.AddItem (Recordset.Fields.Item(3)) Recordset.MoveNext Loop End Sub "Ken" wrote: I am trying to set the rowsource for a combo box from a table in a database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just what I was looking for, is there anyway to populate multiple columns?
"Jeff" wrote: Private Sub UserForm_Initialize() Dim Recordset As ADODB.Recordset Dim SQL As String Set Recordset = New Recordset SQL = "SELECT * FROM returned" '<--- Change to match your table 'The SELECT * will return everything from 'the specified table. Recordset.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly 'open the recordset Do Until Recordset.EOF UserForm1.ComboBox1.AddItem (Recordset.Fields.Item(3)) Recordset.MoveNext Loop End Sub "Ken" wrote: I am trying to set the rowsource for a combo box from a table in a database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub UserForm_Initialize()
Dim Recordset As ADODB.Recordset Dim SQL As String Set Recordset = New Recordset SQL = "SELECT * FROM returned" '<--- Change to match your table 'The SELECT * will return everything from 'the specified table. Recordset.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly 'open the recordset Do Until Recordset.EOF With UserForm1.ComboBox1 .ColumnCount = 3 'Change to suit .AddItem .List(.ListCount - 1, 0) = Recordset.Fields.Item(3) 'Change to suit .List(.ListCount - 1, 1) = Recordset.Fields.Item(4) 'Change to suit 'And So on End With Recordset.MoveNext Loop End Sub "Ken" wrote: I am trying to set the rowsource for a combo box from a table in a database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the post was helpful, please click the 'Yes' button to indicate such!
-- RyGuy "Ken" wrote: Just what I was looking for, is there anyway to populate multiple columns? "Jeff" wrote: Private Sub UserForm_Initialize() Dim Recordset As ADODB.Recordset Dim SQL As String Set Recordset = New Recordset SQL = "SELECT * FROM returned" '<--- Change to match your table 'The SELECT * will return everything from 'the specified table. Recordset.Open SQL, connStr, adOpenForwardOnly, adLockReadOnly 'open the recordset Do Until Recordset.EOF UserForm1.ComboBox1.AddItem (Recordset.Fields.Item(3)) Recordset.MoveNext Loop End Sub "Ken" wrote: I am trying to set the rowsource for a combo box from a table in a database, To no avail. I am using an ADOB connection, open the recordset and try to set the fields value to the rowSource, but I get the error "invalid property value". I also don't see how to have a value in multiple columns. This is my last line of attack. Me.xtype.RowSource = rst.Fields(0).Value Can't help but think I am going about this the wrong way. Any information is greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UserForm ComboBox RowSource linked to Column with duplicate values | Excel Programming | |||
UserForm ComboBox RowSource Problem | Excel Programming | |||
UserForm ComboBox RowSource Question | Excel Programming | |||
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox | Excel Programming | |||
ComboBox RowSource --- can I use a userform OWC10 spreadsheet range? | Excel Programming |