473,799 Members | 2,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.BatchInvoice sList.ItemsSele cted

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

For Each ctl In Me!BatchInvoice sList.ItemsSele cted

What am I doing wrong?

Thanks
Feb 18 '06 #1
3 2373
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.BatchInvoice sList.ItemsSele cted
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"John" <Jo**@nospam.in fovis.co.uk> wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
Hi

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

Dim ctl As Control
For Each ctl In Me.BatchInvoice sList.ItemsSele cted

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

For Each ctl In Me!BatchInvoice sList.ItemsSele cted

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.ItemsSelect ed
Debug.Print ctl.ItemData(va rItm)
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.ItemsSelect ed
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******@pcdata sheet.com


"John" <Jo**@nospam.in fovis.co.uk> wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
Hi

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

Dim ctl As Control
For Each ctl In Me.BatchInvoice sList.ItemsSele cted

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

For Each ctl In Me!BatchInvoice sList.ItemsSele cted

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.n ews.atl.earthli nk.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.ItemsSelect ed
Debug.Print ctl.ItemData(va rItm)
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.ItemsSelect ed
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******@pcdata sheet.com


"John" <Jo**@nospam.in fovis.co.uk> wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
Hi

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

Dim ctl As Control
For Each ctl In Me.BatchInvoice sList.ItemsSele cted

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

For Each ctl In Me!BatchInvoice sList.ItemsSele cted

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
3361
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 variable data. Any clues as to how I can write several items to an SQL statement from a multiselect listbox to update a report? Thanks in anticipation Cassie
1
1985
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 value selection but only for those value that are filtered by first multiselect. I dont know how to connect selected value klient from first multiselect and value product from query and make it source of multiselect 2. Maybe someone did it before...
6
1711
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 page load for updation, i have to reload the selected items again with the same string "1/3/6/8" to be selected in my multiselect list box. Its asking me to convert object to int... for list selection. but how to achieve this..?...
2
1955
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 webform, when there is already admission data. I need the populated list box (lbx_comorb) to show the items that were previously selected for this admission. The selected comorb data is stored in another datatable (dt_ptComorb). If anyone can...
3
3628
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 in a text box? then, how can i have a second selected item show up in a different text box, without affecting the 1st one? (lboxOptions, txtboxOptions0, txtboxOptions1, etc..) -- Greg Message posted via AccessMonster.com
1
1821
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 those list boxes at the time the user clicking the Search button. How do i validate this . Thanks in advance...
1
1790
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 code so much that I am trying to expand it to run off more then one list box. However I can’t get it to work. Original code is below. Private Sub PhotoSearch1_Click() Dim strOr As String Dim strDoc As String Dim varSelect As Variant Dim ctl...
43
3897
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 says that i cannot assign a value to the object, ive tried many ways to get this to work (and i have had this working before)
5
5685
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 that sends out the select rows from lst_country to a msgbox (all working fine). What i need to do now is to actually put those selected rows into an array that I can later parse into another Select * From Table Where < selected lst_country (i,0)> =...
0
9686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9540
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10475
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10026
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.