473,399 Members | 3,401 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,399 software developers and data experts.

Listbox.ItemsSelected

sassy2009
Hello All,

I have got a listbox which lists the files from a network folder. I have set the multiselect property to Extended. What iam trying to do now is display the multiple file names from the listbox. The following is the code which i made but instead of returning the selected items value, the code displays NULL n number of times depending on the itemsSelected.count. For example it displays NULL 5 times if i have selected 5 items from the listbox. Please help.....
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl As Control
  2.  Dim varItm As Variant
  3.  
  4.     Set frm = Forms!Listing
  5.     Set ctl = frm!lstDisplay
  6.     For Each varItm In ctl.ItemsSelected
  7.         Debug.Print ctl.ItemData(varItm)
  8.     Next varItm
Nov 2 '09 #1
2 15409
Thanks Guys i just figured it out. Instead of using ItemData i now used Column(0,VarItm) and it worked.
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl As Control
  2. Dim varItm As Variant
  3.  
  4. Set frm = Forms!Listing
  5. Set ctl = frm!lstDisplay
  6. For Each varItm In ctl.ItemsSelected
  7.   Debug.Print ctl.ItemData(varItm)
  8. Next varItm
Nov 2 '09 #2
NeoPa
32,556 Expert Mod 16PB
Sassy,

Thanks for posting the solution. Finding that without any knowledge of what's in your Listbox columns would have been a little complicated ;)

Please remember also, that all code must be posted in [ CODE ] tags on this site.

NB. Although the explanation is correct, the code posted seems to be the original, unchanged, code.
Nov 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
2
by: Sally | last post by:
I have a simple multiselect listbox with a rowsorce of MemberID, MemberName, SendLetter. SendLetter is a Yes/No field. What is the code to set SendLetter to Yes when the user selects MemberName? I...
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...
5
by: Lisa | last post by:
Hello, I am new to using recordsets, and i am completly stuck with this one. I am trying to use a multi select list box to write records to a table. Something in my code is causing the same...
10
by: SueB | last post by:
Hi. Is there a way to "unselect" items in a listbox, programmatically? Here's what I want to do (and I've been trying to to this while debugging the form, but I've been unsuccessful) ... I...
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...
5
by: juengelj | last post by:
I have four listboxes on my form. When I add a new record, I run the following code to clear list box items... Public Function ClearAll() 'This function clears ALL selected fields in the form's...
2
by: McSwain | last post by:
I'm having alot of trouble getting the selected rows from a listbox set for Extended selection. I've tried using ItemsSelected.Count but it doesn't seem to work consistently. When I select a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.