Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Cannot remove item from collection

I am having trouble removing items from a list box. Here is my code:

Option explicit:

Dim I As Integer

If LstOLd.ListCount = 1 Then
If LstOLd.ListIndex = -1 Then
LstOLd.ListIndex = _
LstOLd.ListCount - 1
End If

LstOLd.RemoveItem (LstOLd.ListIndex)

LstNew.RemoveItem (LstNew.ListIndex)
LstColor.RemoveItem (LstColor.ListIndex)
End If

I also found this:

An error occurred while attempting to remove an item from a collection.
Typically, this is a result of the following:

Attempting to remove a table while it is participating in a relationship
with another table.
Attempting to remove a column while it is defined as a Foreign Key in a
relationship.
Attempting to remove a column that is part of another columns expression.
Attempting to remove a column that is involved in a relationship.
To correct this error

Remove the constraint that this collection item participates in.

Is this perhaps my problem? Thanks.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Cannot remove item from collection

On which line does the error occur? When you try to remove an item from
LstOld, or when you try to remove an item from one of the other boxes? If
the latter, it may be because ListIndex for those boxes is -1 or otherwise
invalid for RemoveItem. Your code covers that possibilty for lstOld, but not
the other 2 boxes.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Kou Vang" wrote in message
...
I am having trouble removing items from a list box. Here is my code:

Option explicit:

Dim I As Integer

If LstOLd.ListCount = 1 Then
If LstOLd.ListIndex = -1 Then
LstOLd.ListIndex = _
LstOLd.ListCount - 1
End If

LstOLd.RemoveItem (LstOLd.ListIndex)

LstNew.RemoveItem (LstNew.ListIndex)
LstColor.RemoveItem (LstColor.ListIndex)
End If

I also found this:

An error occurred while attempting to remove an item from a collection.
Typically, this is a result of the following:

Attempting to remove a table while it is participating in a relationship
with another table.
Attempting to remove a column while it is defined as a Foreign Key in a
relationship.
Attempting to remove a column that is part of another columns expression.
Attempting to remove a column that is involved in a relationship.
To correct this error

Remove the constraint that this collection item participates in.

Is this perhaps my problem? Thanks.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection Object, 255 item limitation timothy[_2_] Excel Programming 4 September 11th 05 09:43 PM
Check for an item in a collection (without looping) Rob Excel Programming 2 February 10th 05 11:18 AM
Retrieving a Collection Item Todd Huttenstine Excel Programming 2 October 27th 04 07:15 PM
Add Unique item to Collection Dick Kusleika[_3_] Excel Programming 8 January 21st 04 08:59 PM
Removing an Item From a Collection Dan Gesshel Excel Programming 4 November 1st 03 01:12 PM


All times are GMT +1. The time now is 09:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"