![]() |
userform combobox rowsource from database
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. |
userform combobox rowsource from database
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. |
userform combobox rowsource from database
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. |
userform combobox rowsource from database
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. |
userform combobox rowsource from database
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. |
userform combobox rowsource from database
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. |
All times are GMT +1. The time now is 09:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com