我有一个多维数组,它将保存 3 位值,并且值将通过从 db 读取通过循环添加。当它出现这行代码时:
*MenuAccess(.Fields("GROUPNO").Value, .Fields("ITEMNO").Value, .Fields("SUBITEMNO").Value) = OKNO*
它遇到错误,“对象引用未设置为对象的实例。”
Public MenuAccess(100, 30, 50) As Boolean
Private Sub RtGetMenu_Access()
Try
Dim OKNO As Boolean
Erase MenuAccess
DBMgr = New cAdodb
With DBMgr
.openCnn(cnnSPR)
.sql(rst1) = "Select * from BSMENU_ACCESS where LEVELCD = '" & Trim(UserTaskLevel) & "' Order by GROUPNO "
.openRstRead(rst1)
With .rst(rst1)
Do While Not .EOF
If .Fields("GROUPNO").Value.ToString.Trim <> "" And .Fields("ITEMNO").Value.ToString.Trim <> "" And .Fields("SUBITEMNO").Value.ToString.Trim <> "" Then
If .Fields("LEVEL1").Value.ToString.Trim = "Y" Then OKNO = True Else OKNO = False
'=> ERROR: 'Object reference not set to an instance of an object.'
MenuAccess(.Fields("GROUPNO").Value, .Fields("ITEMNO").Value, .Fields("SUBITEMNO").Value) = OKNO
End If
.MoveNext()
Loop
End With
.closeRst(rst1)
.closeCnn(rst1)
End With
DBMgr = Nothing
Catch ex As Exception
If DBMgr.cnn(cnnSPR).State <> 0 Then
DBMgr.closeCnn(cnnSPR)
DBMgr = Nothing
End If
End Try
End Sub