By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,490 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,490 IT Pros & Developers. It's quick & easy.

Multiselect list problem

P: n/a
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
Feb 18 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <Jo**@nospam.infovis.co.uk> wrote in message
news:eR**************@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

Feb 18 '06 #2

P: n/a
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
re******@pcdatasheet.com


"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:eR**************@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

Feb 18 '06 #3

P: n/a
--
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" <no****@nospam.spam> wrote in message
news:KI***********@newsread1.news.atl.earthlink.ne t...
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
re******@pcdatasheet.com


"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:eR**************@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



Feb 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.