views:

438

answers:

1

I'm want to use either a hash table or a dictionary in my access program. Apparently, I'm supposed to be using the Microsoft Scripting Runtime Library for this, but it doesn't work.

Dim Dict1 As Dictionary

' Create a dictionary instance.
Set Dict1 = New Dictionary

It can't find the methods ".compareMode" or ".Add":

With Dict1
  'set compare mode
  .CompareMode = BinaryCompare
  ' Add items to the dictionary.
  .Add 1, "Item 1"
  .Add 2, "Item 2"
  .Add 3, "Item 3"
End With

Instead, these are the only one avaiable to me:

.application
.creator
.delete
etc...

Any clues?

+1  A: 

Well, first of all change BinaryCompare to vbBinaryCompare.

And I think you want to be doing your set like this:

Set Dict1 = CreateObject(Scripting.Dictionary)

Edit Just so that it is more visible, here is Anton's eventual solution. He changed the way he declared his dictionary as follows:

Dim SortValues As Scripting.Dictionary 
Set SortValues = New Scripting.Dictionary
CodeSlave
That way didn't work, however it gave me an idea. Dim SortValues As Scripting.Dictionary Set SortValues = New Scripting.DictionaryThat worked. Thanks for the help!
Anton
CodeSlave's original line should have put the class name (Scripting.Dictionary) in double quotes i.e. Dim Dict1 As ObjectSet Dict1 = CreateObject("Scripting.Dictionary")
onedaywhen