B
Brad Pears
I have a list box where the row source is an SQL "select" statment of two
columns from a table - the first column being an ID and the second column
being the ID description that the user is selecting. The user can select
multiple items in the listbox. I can access the ID portion of the listbox
(the 1st column) no probs using the mylstbox.itemdata(i) BUT how do I access
the 2nd column of a selected item using the .columns(x) format?? I tried
many different syntaxes and none seemed to work...
Example...
Table: Test
Fields: 2
FieldNames: "First" and "Last"
table data...
First Last
"Brad" "Pears"
"Terry" "Corbet"
"Paul" "Madden"
ListBox row source: "select * from TEST"
Columns:2
Bound Column: 1
Col Widths:2.54;2.54
The user selects items from the listbox and then the following code runs...
Private Sub Command0_Click()
Dim i As Variant
For Each i In mylstbox.ItemsSelected
' Displays the data in the first column only (i.e. the first names)
MsgBox mylstbox.ItemData(i)
' Now I would also like to display the data in column 2 (the last names)
msgbox ?????????
Next i
End Sub
Any help would be most appreciated!
Thanks,
Brad
columns from a table - the first column being an ID and the second column
being the ID description that the user is selecting. The user can select
multiple items in the listbox. I can access the ID portion of the listbox
(the 1st column) no probs using the mylstbox.itemdata(i) BUT how do I access
the 2nd column of a selected item using the .columns(x) format?? I tried
many different syntaxes and none seemed to work...
Example...
Table: Test
Fields: 2
FieldNames: "First" and "Last"
table data...
First Last
"Brad" "Pears"
"Terry" "Corbet"
"Paul" "Madden"
ListBox row source: "select * from TEST"
Columns:2
Bound Column: 1
Col Widths:2.54;2.54
The user selects items from the listbox and then the following code runs...
Private Sub Command0_Click()
Dim i As Variant
For Each i In mylstbox.ItemsSelected
' Displays the data in the first column only (i.e. the first names)
MsgBox mylstbox.ItemData(i)
' Now I would also like to display the data in column 2 (the last names)
msgbox ?????????
Next i
End Sub
Any help would be most appreciated!
Thanks,
Brad