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

Listbox Do Loop problem...

P: 22
Hi, I have a list box (called genredelete) and i'm trying to write a procedure to delete all the selected items in the list box. The code i have written to do this is as follows:

Expand|Select|Wrap|Line Numbers
  1.         Dim indexnum As Integer
  3.         indexnum = 0
  5.         Do Until indexnum = GenreDelete.ListCount
  7.             If GenreDelete.Selected(indexnum) = True Then
  8.                 GenreDelete.RemoveItem (indexnum)
  9.             Else
  10.                 indexnum = indexnum + 1
  11.             End If
  13.         Loop
The problem is when run only the first selected item is removed and then the loop appears to stop. I have also tried reversing the do loop (so it removes items from the bottom up) and using a for next. However the same problem occurs there as well. Any pointers?
Jan 29 '08 #1
Share this Question
Share on Google+
1 Reply

P: 365
try putting "me." inforont of your listbox name

as in


(or [forms]![frmFormName].[GenreDelete])

that would be my first thought

Jan 29 '08 #2

Post your reply

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