How to specify column number of selected item in listbox (1 Viewer)

MilaK

Registered User.
Local time
Yesterday, 18:38
Joined
Feb 9, 2015
Messages
285
Hello,

I would like to build criteria from selected items of a multicolumn list box. How do I specify the column number that I will use to build the criteria? I only need values from column 1. Thanks

Code:
Set ctl = Me![lst_fusions]

   For Each Itm In ctl.ItemsSelected
      If Len(Criteria) = 0 Then
         Criteria = chr(34) & ctl.ItemData(Itm) & chr(34)
      Else
         Criteria = Criteria & "," & chr(34) & ctl.ItemData(Itm) _
          & chr(34)
      End If
   Next Itm
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:38
Joined
Feb 19, 2013
Messages
16,553
for listboxes and combos, columns start from 0 (although just to be confusing this is bound column 1).

so if it is column 1 (i.e. the second column) then use

ctl.ItemData(Itm).column(1)

or not tested but I think this will also work

ctl.ItemData(Itm,1)
 

MilaK

Registered User.
Local time
Yesterday, 18:38
Joined
Feb 9, 2015
Messages
285
Accually, I get Error 424 Object required with

Code:
For Each Itm In Me.lst_fusions.ItemsSelected
   Debug.Print Me.lst_fusions.ItemData(Itm).Column(0)

It's not recognizing the data in the listbox?
 
Last edited:

MilaK

Registered User.
Local time
Yesterday, 18:38
Joined
Feb 9, 2015
Messages
285
Ok, Me.lst_fusions.ItemData(1).Column(0) doesn't work but if i bind column 2 then I can just use ctl.ItemData(Itm) to get values in from the second column.

Mila
 

Users who are viewing this thread

Top Bottom