J
JP
Multi Select list box and the bound column....
Hello all,
Req any help with the following:
I have a multi select list box that contains data from a
table. The table has two columns. Column 1 is a numerical
value, column two is text.
When a user makes selections from the text (column 1)
displayed in the listbox, the numerical tally (column 2)
of those choices is displayed in a text box. The code for
which is as follows:
Private Sub listBox_AfterUpdate()
Dim ctlList As Control, varItem As Variant
Dim a As Long
' Return Control object variable pointing to list box.
Set ctlList = Me.listBox
' Enumerate through selected items.
For Each varItem In ctlList.ItemsSelected
' Print value of bound column.
'Debug.Print ctlList.ItemData(varItem)
a = a + ctlList.ItemData(varItem)
Next varItem
'Debug.Print a
TextBox.Value = a
End Sub
My question is this: This appears to be the result of
column 1 (numerical values) being the bound column. Is
there anyway to make this happen with column 2 as the
bound column? The reason I ask, is because I need to keep
the tally feature, but also need to display the selected
text items in a combo box.
JP
Hello all,
Req any help with the following:
I have a multi select list box that contains data from a
table. The table has two columns. Column 1 is a numerical
value, column two is text.
When a user makes selections from the text (column 1)
displayed in the listbox, the numerical tally (column 2)
of those choices is displayed in a text box. The code for
which is as follows:
Private Sub listBox_AfterUpdate()
Dim ctlList As Control, varItem As Variant
Dim a As Long
' Return Control object variable pointing to list box.
Set ctlList = Me.listBox
' Enumerate through selected items.
For Each varItem In ctlList.ItemsSelected
' Print value of bound column.
'Debug.Print ctlList.ItemData(varItem)
a = a + ctlList.ItemData(varItem)
Next varItem
'Debug.Print a
TextBox.Value = a
End Sub
My question is this: This appears to be the result of
column 1 (numerical values) being the bound column. Is
there anyway to make this happen with column 2 as the
bound column? The reason I ask, is because I need to keep
the tally feature, but also need to display the selected
text items in a combo box.
JP