I'm using a dictionary to build a list of keys and values.
The keys comes from a recordset (stringfield), the items are Excel-columns (A, B, C etc). The code determines the Excelcolumn based on a "columnname" in the table Meta by searching for a column with the corresponding name, then gets the Excel columnnumber, and adds both to a Dictionary
The dictionary holds the columnnames and corresponding columnumber
In my recordset rstMeta there are 4 columnnames and numbers that need to be added (NUMBER, BRIDGETYPE_ID, DESCRIPTION, WEIGHT) to the dictionary
When I run this it generates an error when adding the second columnname (BRIDGETYPE_ID) stating that the key already exists (which is not true since I have 4 unique values looping through rstMeta).
I found that when I do this:
it works....the same second value/key (BRIDGETYPE_ID) can be added without problem and my dictionary is filled as I intended with 4 "records"
I have absolutely no idea why adding "( )" would fix my problem... Anybody that can explain this?
The keys comes from a recordset (stringfield), the items are Excel-columns (A, B, C etc). The code determines the Excelcolumn based on a "columnname" in the table Meta by searching for a column with the corresponding name, then gets the Excel columnnumber, and adds both to a Dictionary
The dictionary holds the columnnames and corresponding columnumber
In my recordset rstMeta there are 4 columnnames and numbers that need to be added (NUMBER, BRIDGETYPE_ID, DESCRIPTION, WEIGHT) to the dictionary
Code:
With dictA
dictA.compare = vbTextCompare
do while not rstMeta.EOF
"some code that searches for the matching column in xlSht...."
.add rstMeta!MetaValue, Split(xlSht.Cells(x, y).ADDRESS, "$")(1)
rstMeta.movenext
loop
End With
When I run this it generates an error when adding the second columnname (BRIDGETYPE_ID) stating that the key already exists (which is not true since I have 4 unique values looping through rstMeta).
I found that when I do this:
Code:
.add [COLOR="Red"]([/COLOR]rstMeta!MetaValue[COLOR="Red"])[/COLOR], Split(xlSht.Cells(x, y).ADDRESS, "$")(1)
I have absolutely no idea why adding "( )" would fix my problem... Anybody that can explain this?