Reputation: 3
I have a combobox that gets populated with information sourced from an Access Database. I have a method that opens up records using a ADO Recordset. I have a multicolumn combobox that I want to select a value from the populated list on the form. For single column combobox's, the value that gets shown on the form is populated using the value property as shown below.
frmDataEntry.txtProcessID = sourceRS.Fields("ProcessID").Value
I am having issues populating a multicolumn combobox as the Value property does not work.
Do Until y >= frmDataEntry.cmbProcess.listCount
If frmDataEntry.cmbProcess.List(y, 0) = sourceRS.Fields("ProcessID").Value Then
'This is where i'd like to set the value
End If
y = y + 1
Loop
In the code above, if this were a listbox, i would use .Selected(y) = True
property but that is not available for comboboxes. Does anybody have any suggestions? I have searched everywhere but cannot seem to find a way to do this without wiping out the populated list of the combobox.
Upvotes: 0
Views: 1501
Reputation: 940
I'm not exactly sure what you're trying to do, but if your problem is displaying an already added value, frmDataEntry.cmbProcess.ListIndex = y
will do exactly that for 0 <= y < ListCount
.
Upvotes: 1
Reputation: 1506
Normally this is what I do. I put the values into an array then do this:
Dim MyArray() As String
'Here you want to populate MyArray
With Me.combobox1
.ColumnCount = 2
.BoundColumn = 2
.ColumnWidths = "2.5 in; 0 in"
.List = MyArray
End With
Upvotes: 0