Tark221
Registered User.
- Local time
- Today, 04:18
- Joined
- Oct 12, 2012
- Messages
- 74
Hi all,
Apologies if I've posted this in the wrong section of the forum, I wasn't sure if it was more of an Access or Excel question.
Just a bit of background on my problem. I have a combobox and a listbox on an Excel Form, on the combobox change event I query an Access Database which populates this listbox. The criteria of the query is the value of the combo box. It all seems to be working fine except when the list box populates with a record instead of going from left to right, it just stacks like in a list. I don't know if anyone has had any trouble with this before.
This is my code:
Any help would be much appreciated.
Apologies if I've posted this in the wrong section of the forum, I wasn't sure if it was more of an Access or Excel question.
Just a bit of background on my problem. I have a combobox and a listbox on an Excel Form, on the combobox change event I query an Access Database which populates this listbox. The criteria of the query is the value of the combo box. It all seems to be working fine except when the list box populates with a record instead of going from left to right, it just stacks like in a list. I don't know if anyone has had any trouble with this before.
This is my code:
Code:
'~~> Database NameConst mdbPath = "C:\Users\bill\Documents\Current Projects\Knowledge\Excel Version\Database\db1.mdb"
'~~> Connection String
Const strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbPath & ";"
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim MyArray As Variant
Dim sSQL As String
sSQL = "SELECT * from Process where parentname ='Registering'"
cn.Open strCon
'~~> Open recordset and copy to an array
rs.Open sSQL, cn
MyArray = rs.GetRows
'~~> Update listbox
With Me.lbSearch
.Clear
.ColumnCount = 5
.List = Application.Transpose(MyArray)
.ListIndex = -1
End With
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
Any help would be much appreciated.