+ Reply to Thread
Results 1 to 3 of 3

Key is already associated with an element of this collection...

  1. #1
    Registered User
    Join Date
    08-27-2014
    Location
    Albany, NY
    MS-Off Ver
    Office 2010
    Posts
    91

    Key is already associated with an element of this collection...

    I am at a loss. I came back from vacation and now this isn't work, when it had been working previously. Can anyone tell me why? (It is still on vacation is not a valid reply LOL) It is failing on this line "DistrictNums.Add CurrentName, CurrentNum" obviously. I am adding a list of congressional districts and their reps, so I may have multiple of "dist 1:Mary smith" relationships that subsequent "dist 1:Mary smith" relationships would just be ignored after they are added the first time. This is where it is hanging up.

    Please Login or Register  to view this content.
    Last edited by Coleman34; 11-06-2014 at 12:43 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Key is already associated with an element of this collection...

    What does "failing" mean?

    It appears that if there are duplicates in the list, that you want to show the user a message somehow (we don't know what RaiseError does).

    So what actually happens?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Moscow
    MS-Off Ver
    Office 365
    Posts
    100

    Re: Key is already associated with an element of this collection...

    Check: Tools-Optons-General-groupe Error Trapping. Use "Break on unhandled Errors". Now you have probably found "Break on All Errors"

    so you can use a dictionary instead of a collection. Error handling when not required.:
    Please Login or Register  to view this content.
    Last edited by The_Prist; 11-06-2014 at 03:41 PM. Reason: add code with dictionary object
    I'm sorry my english...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Adding new element to a collection propagatres added value to all entries
    By tfurnivall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2014, 06:09 PM
  2. Replies: 12
    Last Post: 01-14-2014, 01:56 PM
  3. [SOLVED] Performance of iteration through Words collection degrades as collection gets bigger
    By 6StringJazzer in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2014, 09:44 AM
  4. [SOLVED] Stat table with formulas for each data element but only when the element exists in table
    By stevemills04 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2013, 05:50 AM
  5. Replies: 2
    Last Post: 12-23-2011, 11:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1