Private Sub lstSubFunc_Click()
On Error GoTo errH
With lstSubFunc
LoadFunc = False
If .Row < 0 Then .Row = 0
If .TextMatrix(.Row, 1) = "" Then Exit Sub
curFunctionID = .TextMatrix(.Row, 1)
If curFunctionID = 0 Then Exit Sub
.Cell(flexcpFontBold, 1, 0, .Rows - 1, 0) = 0
.Cell(flexcpFontBold, .Row, 0, .Row, 0) = 1 RsFuncS.Filter = "FSUBFUNCID = " & curFunctionID
If RsFuncS.EOF Then
lstDetailFunc.Visible = False
Exit Sub
Else
lstDetailFunc.Visible = True
End If
ImgArrowS.Move lstSubFunc.CellLeft, lstSubFunc.CellTop + ImgArrowS.Height / 4
ImgArrowD.Move 0, lstDetailFunc.RowHeightMin + ImgArrowD.Height / 4
End With
With lstDetailFunc
.Rows = 1
RsFuncS.MoveFirst
Do Until RsFuncS.EOF
.AddItem Space(3) & RsFuncS(1) & Chr(9) & RsFuncS(0)
RsFuncS.MoveNext
Loop
.Row = 1
LoadFunc = True
'.Height = .Rows * .RowHeightMin + 100
.Move .Left, lstSubFunc.Top + lstSubFunc.CellTop
'.Height = Me.ScaleHeight - .Top - 600
.Height = Me.ScaleHeight - .Top
End With
errH:
If err.Number <> 0 Then
MsgBox err.Description, 64
Exit Sub
End If
End Sub
Public RsFuncS As ADODB.Recordset
第一次执行lstSubFunc_Click正常,第二次执行lstSubFunc_Click就报错“对象已关闭,不允许操作。”,我这个是Public类型的,也没有对它做关闭操作,为什么就不行了呢?
同时设置.Rows = 1 和 RsFuncS.MoveFirst
Private Sub lstSubFunc_Click()
On Error GoTo errH
With lstSubFunc
LoadFunc = False
If .Row < 0 Then .Row = 0
If .TextMatrix(.Row, 1) = "" Then Exit Sub
curFunctionID = .TextMatrix(.Row, 1)
If curFunctionID = 0 Then Exit Sub
.Cell(flexcpFontBold, 1, 0, .Rows - 1, 0) = 0
.Cell(flexcpFontBold, .Row, 0, .Row, 0) = 1 RsFuncS.Filter = "FSUBFUNCID = " & curFunctionID
If RsFuncS.EOF Then
lstDetailFunc.Visible = False
Exit Sub
Else
lstDetailFunc.Visible = True
End If
ImgArrowS.Move lstSubFunc.CellLeft, lstSubFunc.CellTop + ImgArrowS.Height / 4
ImgArrowD.Move 0, lstDetailFunc.RowHeightMin + ImgArrowD.Height / 4
End With
With lstDetailFunc
.Rows = 1
if Not RsFuncS.BoF Then RsFuncS.MoveFirst
Do
.AddItem Space(3) & RsFuncS(1) & Chr(9) & RsFuncS(0)
RsFuncS.MoveNext
Loop Until RsFuncS.EOF
.Row = 1
LoadFunc = True
'.Height = .Rows * .RowHeightMin + 100
.Move .Left, lstSubFunc.Top + lstSubFunc.CellTop
'.Height = Me.ScaleHeight - .Top - 600
.Height = Me.ScaleHeight - .Top
End With
errH:
If err.Number <> 0 Then
MsgBox err.Description, 64
Exit Sub
End If
End Sub