refer to second column of listbox

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,


I have a multi selected listbox. How can I refer to the second column of the
listbox?
Me.lstContract.ItemData(varItem).column(1) ???

Dim varItem As Variant

For Each varItem In Me.lstContract.ItemsSelected
gstrReportFilter = "[Ck_ContractID]='" &
Me.lstContract.ItemData(varItem) & "'"
''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter
DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', ,
gstrReportFilter
Next varItem


SF
 
Al Campagna said:
SF,
When a value has been selected, it should be just...
lstContract.Column(1)

Not for a multiselect combo box -- then you need to index the row as well as
the column:

.Me.lstContract.Column(1, varItem)
 
SF -

The columns in a list box, combo box, or drop-down list box start with 1
(first column). You can just use Me.lstContract.column(2) for the second
column.
 
If you want to refer to specific column and specific row
Me.ListContract.Column(2,50)
Refers to the third column of the 51st row.

So I believe (you can test) you can get the appropriate value using
me.ListContract.Column(1,VarItem)

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Daryl S said:
SF -

The columns in a list box, combo box, or drop-down list box start with 1
(first column). You can just use Me.lstContract.column(2) for the second
column.


I'm sorry, but that is wrong. The Columns collection is 0-based, so the
first column is .Column(0).
 
Sorry - I was thinking of the bound column of a list box, combo box, or
drop-down, which start with 1, since the list index is used for zero. To
refer to a column in code, you start with zero for both columns and rows...
 
Back
Top