If e.Node.Level = 0 Then '如果是顶层节点
Return '则返回
Else
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim ids As String
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
For Each nd In e.node.allNodes '清除子节点的选中标记
nd.Checked = False
Next
pd = e.Node.ParentNode
Do While pd IsNot Nothing '清除父节点的选中标记
pd.Checked = False
pd = pd.ParentNode
Loop
For Each nd In trv.AllNodes
pd = nd
Do While pd IsNot Nothing
If pd.Checked Then
If ids > "" Then
ids= ids & ","
End If
ids = ids & nd.DataRow("编号")
Exit Do
Else
pd = pd.ParentNode
End If
Loop
Next
If ids > "" Then
Tables("表B").Current("编号") = IDS
End If
End If