我可以在ms访问中使用多个哈希表吗?

时间:2017-06-14 00:12:02

标签: ms-access

ms访问是否在perl中提供类似hash {key1} {key2} {key3} [num]的哈希表?或者任何变通方法? 我尝试下面模仿它但我无法将recordNum数组添加到dType中。当我使用断点时,当我为1时,控制不能进入If Not dType.exists(rst!serviceType) Then dType.Add rst!serviceType, recordNum(i) End If的if子句。

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

1 个答案:

答案 0 :(得分:0)

您没有移动记录集,您可能必须更明确:

    Dim i As Integer

    Do Until rst.EOF
        recordNum(i) = assetServiceTime(rst!serviceName) / 60

        If Not dType.exists(rst!serviceType.Value) Then
            dType.Add rst!serviceType.Value, recordNum(i)
        End If
        If Not dType.exists(rst!chNum.Value) Then
            dNum.Add rst!chNum.Value, dType
        End If
        If Not dType.exists(rst!chName.Value) Then
            dName.Add rst!chName.Value, dNum
        End If

        i = i + 1
        rst.MoveNext
    Loop 
    rst.Close