469,927 Members | 1,589 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.


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
  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 14471
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
  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
32,232 Expert Mod 16PB

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

Post your reply

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

Similar topics

2 posts views Thread by Sally | last post: by
2 posts views Thread by Cassie Pennington | last post: by
3 posts views Thread by kaosyeti via AccessMonster.com | last post: by
2 posts views Thread by McSwain | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.