Does ms access provide hash table like hash{key1}{key2}{key3}[num] in perl? Or any workarounds?
I tried below to imitate it but I couldn't add array of recordNum into dType. When I use breakpoint, control can't go into if-clause of If Not dType.exists(rst!serviceType) Then dType.Add rst!serviceType, recordNum(i) End If
when i is 1.
Private Sub serviceInfo()
Dim dName As Object
Dim dNum As Object
Dim dType As Object
Dim recordNum(2048) As Integer
Set dName = CreateObject("Scripting.Dictionary") 'Create the Dictionary
Set dNum = CreateObject("Scripting.Dictionary") 'Create the Dictionary
Set dType = CreateObject("Scripting.Dictionary") 'Create the Dictionary
Set dbs = CurrentDb
qStr = "SELECT yearMonth, clName, certiNum, chName, chDateBirth, chNum, serviceType, serviceName " & _
"FROM tblList " & _
"WHERE tblList.chName=" & "'" & Me.Form.fchName & "';"
Set rst = dbs.OpenRecordset(qStr)
If Not (Err.Number = 0) Then ' if error
MsgBox "An error occured (Error Number " & Err.Number & _
": " & Err.Description & ")"
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub
ElseIf rst.BOF And rst.EOF Then
cantFindRecordYoyang = 1
'rst.Close
End If
With rst
Dim i As Integer
Do Until rst.EOF
recordNum(i) = assetServiceTime(rst!serviceName) / 60
If Not dType.exists(rst!serviceType) Then
dType.Add rst!serviceType, recordNum(i)
End If
If Not dType.exists(rst!chNum) Then
dNum.Add rst!chNum, dType
End If
If Not dType.exists(rst!chName) Then
dName.Add rst!chName, dNum
End If
i = i + 1
Loop ' // End do
End With
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub