refer to second column of listbox

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
 
D

Dirk Goldgar

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)
 
D

Daryl S

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.
 
J

John Spencer

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
 
D

Dirk Goldgar

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).
 
D

Daryl S

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top