If rs.State And adStateOpen Then rs.Close
    strSQL = "Select id,pname,name From menuaction order by id,pname"
    rs.Open strSQL, cn, adOpenStatic
 
    For i = 0 To 7
        pname = rs!pname
        For j = 0 To rs.RecordCount - 1
            With TreeView1(i)
                Set snode = .Nodes.add(, , "item_" & rs!id, rs!name, 1, 1)
                '如果在操作员权限表manaction中,找到相应的id,则此项目要选中
                If rstemp.State And adStateOpen Then rstemp.Close
                rstemp.Open "select * from manaction where name='" & P_name & "' and id=" & rs!id, cn, adOpenStatic
                If rstemp.RecordCount > 0 Then
                    snode.Checked = True
                End If
                'snode.Tag = rs!id
            End With
            rs.MoveNext
            'pname = rs!pname
            If pname <> rs!pname Then pname = rs!pname: Exit For
        Next j
    Next i可以运行,但没有snode.Checked = True的效果