|
-
July 4th, 2001, 10:33 AM
#1
Please help - Error 457 - Index already associated with this item.
Simple form used to input 2 strings (key & value), to be stored in Dictionary (dictLocations)which is instantiated in Module1. Works fine until user clicks yes in message box, then get Error 457 (duplicate key)???
Thanks for anyone's help!
private Sub cmdOK_Click()
Dim key as string, val as string
dictLocations.Add tbLocNo, tbLocDesc
If MsgBox("Add Another Location?", vbYesNo) = vbYes then
me.Hide
tbLocNo = ""
tbLocDesc = ""
me.Show
else
me.Hide
End If
Unload.me
End Sub
-
July 4th, 2001, 12:25 PM
#2
Re: Please help - Error 457 - Index already associated with this item.
It sames that the key (tbLocNo) of dictLocations is not unique. I don't know how you get the value of tbLocNo before calling dictLocation.Add, but if it is possible that tbLocNo is duplicate, try to add a suffix to make it unique. For example:
dictLocation.Add tbLocNo & CStr(intCounter), tbLocDesc
Regards,
Michi
MCSE, MCDBA
-
July 4th, 2001, 07:06 PM
#3
Re: Please help - Error 457 - Index already associated with this item.
The FIRST key value is changing anytime tbLocNo changes. I don't understand why, but when the user enters a SECOND key value in the textbox, the FIRST key entry in the dict changes to that value. Thus, when the Add method is called, the key is already in the dictionary. (?)
Thanks for your help.
John R.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|