Unloading a Combo box...

tebule

Registered User.
Local time
Today, 07:30
Joined
Oct 8, 2008
Messages
38
I have search the threads and came accross thread: Update ListBox from CheckBox

But that did not help me.

Here is my problem: I am trying to unload a combo box. I have five items in my combo box. When it get to item number three it throws error 6013: Unable to remove item. '3' not found in list. If I end and run the code again it works until it gets to the last indexed item and then if I hit end it runs again and it works.

I would like to unload all of the items. I don't know what I am doing wrong..

Here is my code:
Private Sub cmdReDo_Click()
Dim x As Integer
Dim y As Integer
'Empties the combo list of all of the file names.
y = Me.cboFileList.ListCount - 1
For x = 0 To y
Me.cboFileList.RemoveItem (x)
Next

It is almost as if the listcount looses it's place. :confused:
Thanks in advance for any help.
 
Change

For x = 0 To y

to

For x = y To 0 Step -1
 
Are you trying to empty out all items from the combobox? If so a single line is all that's needed:

cboFileList.RowSource = ""
 
Thanks all for the help!! missinglinq: that worked perfectly!!! Thanks.
 
Yeah, sometimes I get focused on answering the question and ignore the obvious. Negative rep points for my post here :)
 
No, please. I really appriciated both. With yours I could see what I was doing wrong in my code. Thanks again.
 

Users who are viewing this thread

Back
Top Bottom