Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 590
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 590
Default 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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default 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.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default 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.

Reply
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
UserForm ComboBox RowSource linked to Column with duplicate values PCLIVE Excel Programming 2 April 11th 08 05:06 PM
UserForm ComboBox RowSource Problem Minitman[_4_] Excel Programming 0 January 4th 06 05:22 AM
UserForm ComboBox RowSource Question Minitman[_4_] Excel Programming 0 November 15th 05 07:03 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM
ComboBox RowSource --- can I use a userform OWC10 spreadsheet range? Dean Frazier Excel Programming 0 February 11th 04 07:16 PM


All times are GMT +1. The time now is 04:03 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"