View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve Roberts Steve Roberts is offline
external usenet poster
 
Posts: 11
Default Multi Column ComboBox

Is there a way to make a ComboBox show 2 columns and fill them with info
from a database? I have looked at a bunch of examples and have sucessfully
created a 2 column listbox and tried using that as a launching point for a 2
column combo box. I can't seem to get it figured out. Here is the code I
came up with so far.

Thanks in advance for your suggestions.

Steve

Private Sub CommandButton2_Click()

Dim intColumnCount As Integer
Dim conn As ADODB.Connection
Dim rsPlot As ADODB.Recordset

Set conn = New ADODB.Connection

With conn

.Provider = "SQLOLEDB.1"
.ConnectionString = _
"Password=XXXXXX;Persist Security Info=True;User
ID=structural;Initial Catalog=Advantage; Data Source=ACCOUNT"

conn.Open

End With

' Select the data.
Set rsPlot = conn.Execute("SELECT
Advantage.dbo.CLA.claAddressee,Advantage.dbo.CLA.c laCity FROM
Advantage.dbo.CLA Order By Advantage.dbo.CLA.claAddressee")

Do While Not rsPlot.EOF

ComboBox1.List(intColumnCount, 0) = rsPlot!claAddressee
ComboBox1.List(intColumnCount, 1) = rsPlot!claCity

rsPlot.MoveNext

intColumnCount = intColumnCount + 1

Loop


End Sub