Home > Archive > MS Access database support > February 2006 > Multiselect list problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Multiselect list problem
John

2006-02-18, 8:24 pm

Hi

I am using the following get the items from a multiselect list;

Dim ctl As Control
For Each ctl In Me.BatchInvoicesList.ItemsSelected

Problem is that I am getting a 'Object not found error'. Same with;

For Each ctl In Me!BatchInvoicesList
.ItemsSelected

What am I doing wrong?

Thanks


Douglas J. Steele

2006-02-18, 8:24 pm

The ItemsSelected collection doesn't return a control. It's a collection of
Variants, where each Variant is an integer index referring to a selected row
in the list box. Try:

Dim ctl As Variant

For Each ctl In Me.BatchInvoicesList.ItemsSelected


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John" <John@nospam.infovis.co.uk> wrote in message
news:eRPd6GMNGHA.2528@TK2MSFTNGP12.phx.gbl...
> Hi
>
> I am using the following get the items from a multiselect list;
>
> Dim ctl As Control
> For Each ctl In Me.BatchInvoicesList.ItemsSelected
>
> Problem is that I am getting a 'Object not found error'. Same with;
>
> For Each ctl In Me!BatchInvoicesList
.ItemsSelected
>
> What am I doing wrong?
>
> Thanks
>
>



PC Datasheet

2006-02-18, 8:24 pm

ItemsSelected is a collection of Variants!

From the Help file ----
Sub BoundData()
Dim frm As Form, ctl As Control
Dim varItm As Variant

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
Debug.Print ctl.ItemData(varItm)
Next varItm
End Sub

The next example uses the same list box control, but prints the values of
each column for each selected row in the list box, instead of only the
values in the bound column.

Sub AllSelectedData()
Dim frm As Form, ctl As Control
Dim varItm As Variant, intI As Integer

Set frm = Forms!Contacts
Set ctl = frm!Names
For Each varItm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount - 1
Debug.Print ctl.Column(intI, varItm)
Next intI
Debug.Print
Next varItm
End Sub


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1125 users have come to me from the newsgroups requesting help
resource@pcdatasheet
.com




"John" <John@nospam.infovis.co.uk> wrote in message
news:eRPd6GMNGHA.2528@TK2MSFTNGP12.phx.gbl...
> Hi
>
> I am using the following get the items from a multiselect list;
>
> Dim ctl As Control
> For Each ctl In Me.BatchInvoicesList.ItemsSelected
>
> Problem is that I am getting a 'Object not found error'. Same with;
>
> For Each ctl In Me!BatchInvoicesList
.ItemsSelected
>
> What am I doing wrong?
>
> Thanks
>
>



PleaseStopAdvertising

2006-02-19, 3:24 am

--
To anyone that reads this message thread, you should be aware that PC
Datasheet is notorious for advertising in newsgroups that are intended for
the *free* exchange of Access help. There are numerous consultants that
provide free expert support here. Datasheet has been repeatedly asked to
stop, but refuses.

If you would like to know more about this individual, please use the link
below.

http://home.tiscali.nl/arracom/whoissteve.html

Randy Harris



"PC Datasheet" <nospam@nospam.spam> wrote in message
news:KILJf.6$S25.2@newsread1.news.atl.earthlink.net...
> ItemsSelected is a collection of Variants!
>
> From the Help file ----
> Sub BoundData()
> Dim frm As Form, ctl As Control
> Dim varItm As Variant
>
> Set frm = Forms!Contacts
> Set ctl = frm!Names
> For Each varItm In ctl.ItemsSelected
> Debug.Print ctl.ItemData(varItm)
> Next varItm
> End Sub
>
> The next example uses the same list box control, but prints the values of
> each column for each selected row in the list box, instead of only the
> values in the bound column.
>
> Sub AllSelectedData()
> Dim frm As Form, ctl As Control
> Dim varItm As Variant, intI As Integer
>
> Set frm = Forms!Contacts
> Set ctl = frm!Names
> For Each varItm In ctl.ItemsSelected
> For intI = 0 To ctl.ColumnCount - 1
> Debug.Print ctl.Column(intI, varItm)
> Next intI
> Debug.Print
> Next varItm
> End Sub
>
>
> --
> PC Datasheet
> Your Resource For Help With Access, Excel And Word Applications
> Over 1125 users have come to me from the newsgroups requesting help
> resource@pcdatasheet
.com
>
>
>
>
> "John" <John@nospam.infovis.co.uk> wrote in message
> news:eRPd6GMNGHA.2528@TK2MSFTNGP12.phx.gbl...
>
>


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com