473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Multiselect list problem

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
3 2352
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
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
--
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cassie Pennington | last post by:
I am trying to write various items from a multiselect list box to an SQL statement to update a report, without success. SQL only appears to accept hard-coded data or control values from a form, not...
1
by: tod4 | last post by:
Hi, My problem: I have query with value klient and product. On my form Im using multiselect box as filter of klient value. Now I would like to use second multiselect on this form for product...
6
by: ¿ Mahesh Kumar | last post by:
Hi groups, Control name : ListboxID (lstCertification), selection mode=mutliselect. On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the...
2
by: Steph | last post by:
I have created a multiselect list box control (lbx_comorb) that is populated from a datatable (dt_ptAdmission). The list box populates now problem at all. However the issue is when I load the...
3
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up...
1
by: syam | last post by:
Hai Friends.. I have a search page and contains multiple multiselect list boxes, each containing 6 options. I want to check whether the user has checked atleast one option in each of...
1
by: Redbeard | last post by:
I am a newbie running Access 2003. A couple of weeks back a member named ADezil help me write a code that let a , MultiSelect Listboxs that run a Query on a Form (many thanks). I have used this...
43
by: Dan2kx | last post by:
Hello AGAIN 'Nother problem to solve.... im trying to set the MultiSelect property within VB for a list box, and i am using the code Me.StaffHols.Multiselect = True and it wont work, it...
5
by: erbrose | last post by:
Hey all, newbie to vb here. I've created a listbox (called lst_county) that gets populated from a Select * From Table in Oracle on load. I've set the MultiSelect to 2 -Extended. I've got some code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.