How to read 2nd column of a list box?

S

SW

Hello, my multi-select list box that has 2 columns, called Ex_Code and
Auth_Ex. I am trying to append the selected items in the list box to a table
called "Update Tbl". I know how to read the first column by using
Me.lstAuth_Ex.ItemData(iCount), but I don't know how to read the 2nd column.
I am trying Me.lstAuth_Ex.Column(1, iCount) to read the 2nd column, but this
code return null value. Any insight will be helpful!!

This is my current code:

Set rstSel = db.OpenRecordset("UpdateTbl")
If Me.lstAuth_Ex.ListCount <> 0 Then
For iCount = 0 To Me.lstAuth_Ex.ListCount - 1
Me.lstAuth_Ex.Selected(iCount) = True
With rstSel
.AddNew
.Fields(0) = Me.txtSelBusLine.Value
.Fields(1) = Me.lstAuth_Ex.ItemData(iCount) 'Ex_Code
.Fields(2) = Me.lstAuth_Ex.Column(1, iCount) 'Exchange Name
.Update
End With
Me.lstAuth_Ex.Selected(iCount) = False
Next
End If
 
D

Douglas J. Steele

Me.lstAuth_Ex.Column(1, iCount) is the correct way to read the second column
of row iCount.

Are you sure that the RowSource doesn't contain more than 2 columns, and
that the 2nd column is actually hidden in the list box?
 
S

SW

Thanks, it is my fault. Yes, the code is correct, it is the table that it is
reading from has null values.
 
Top