|
[:28]请 fans 职教一下,我刚好也碰到类是问题:我建立一个 部门树,希望 点击部门后,在下级节点 添加 该部门内的人员, 已基本实现,但是如果重新点击 该部门后,提示错误: key 不是唯一
Private Sub Form_Load()
Me.Trv.Nodes.Clear '清除Treeview控件中的所有节点
Call AddMyTree(Trv, "usysDepartment", "Dept_ParentID", "Dept_ID", "Dept_Name")
Me.Trv.SetFocus
End Sub
Private Sub Trv_NodeClick(ByVal Node As Object)
'MsgBox Node.Index & "****" & Node.Tag
Rec.Open "select * from EmploymentInfo where EMP_Units='" & Node & "'", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If Rec.RecordCount > 0 Then
For i = 0 To Rec.RecordCount - 1
Set Nodeindex = Trv.Nodes.Add(Node, tvwChild, "e" & Rec.Fields("EMP_ID"), Rec.Fields("EMP_Name"), 1, 2)
Node.Tag = Rec.Fields("EMP_ID")
Node.Sorted = True
Rec.MoveNext
Next
End If
Rec.Close
Me.Trv.Refresh
[ 本帖最后由 mopems 于 2008-8-28 14:51 编辑 ] |
|