Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Multi-Select listbox selection order

Geek News

Multi-Select listbox selection order
TonyT 12/12/2008 10:23:01 AM
Hi,

I'm using a multiSelect listbox, but need to know the order that the items
were selected. Is there a way to do this without *lots* of coding after each
item has been selected (I know I'll need some coding to de-select the whole
list if the primary selection is de-selected) ie. can the ItemsSelected
property be ordered in such a way?

Re: Multi-Select listbox selection order
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/12/2008 11:48:55 AM
"TonyT" <TonyT[ at ]discussions.microsoft.com> wrote in message
news:010BABED-279B-43ED-96F3-0CE7B6CC8F96[ at ]microsoft.com...
[Quoted Text]
> Hi,
>
> I'm using a multiSelect listbox, but need to know the order that the items
> were selected. Is there a way to do this without *lots* of coding after
> each
> item has been selected (I know I'll need some coding to de-select the
> whole
> list if the primary selection is de-selected) ie. can the ItemsSelected
> property be ordered in such a way?

No the ItemsSelected collection is read-only. You can, however, maintain
your own collection, by adding to it in the OnClick event:

With Me.ListboxName
If .Selected(.ListIndex) Then
MyCollection.Add .ListIndex
End If
End With

Then you can read them out of MyCollection, in clicked on order. To clear
MyCollection, just do:

Set MyCollection = New Collection


Re: Multi-Select listbox selection order
TonyT 12/12/2008 12:18:01 PM
Thanks Stuart,

Now why didn't I think of that? As usual overlooking the obvious in search
of complication....<g>

TonyT..

"Stuart McCall" wrote:

[Quoted Text]
> "TonyT" <TonyT[ at ]discussions.microsoft.com> wrote in message
> news:010BABED-279B-43ED-96F3-0CE7B6CC8F96[ at ]microsoft.com...
> > Hi,
> >
> > I'm using a multiSelect listbox, but need to know the order that the items
> > were selected. Is there a way to do this without *lots* of coding after
> > each
> > item has been selected (I know I'll need some coding to de-select the
> > whole
> > list if the primary selection is de-selected) ie. can the ItemsSelected
> > property be ordered in such a way?
>
> No the ItemsSelected collection is read-only. You can, however, maintain
> your own collection, by adding to it in the OnClick event:
>
> With Me.ListboxName
> If .Selected(.ListIndex) Then
> MyCollection.Add .ListIndex
> End If
> End With
>
> Then you can read them out of MyCollection, in clicked on order. To clear
> MyCollection, just do:
>
> Set MyCollection = New Collection
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net