Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top