We help IT Professionals succeed at work.

Cannot append object already in collection.

I get the above error I tried on msdn to find what causes this.

Can anybody give an explanation?

THanks

Gabriel
Comment
Watch Question

Commented:
What collection are you appending to?
If you don't want duplicates, just trap the error on the add, and ignore it.

Commented:
You are trying to add an object to a collection, and the key of that object already exist there.
This probably happened because you used:
coll.add .....

Author

Commented:
Basically I cache a recordset by making a copy of it then
before I step through it I get the error.

I think it's difficult to explain.

Iwill  try to think of a better way to explain it.

thanks
gabriel
Commented:
Hello Gabriel_Brienza !

You can't make a copy of a recordset by adding it twice in a collection because it is a reference to the same memory location.

1. You can open a second recorset and add it to the collection.
2. You can use the recordest.clone method to make a colne of it.

V.K.

Author

Commented:
Thanks
I will use the recordset.clone

gabriel