Set Rec = New ADODB.Recordset
Rec.Open "select DISTINCT 上级ID,合同ID,合同编号 from 合同明细查询 ", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
For i = 0 To Rec.RecordCount - 1
Set nodex = TreeView.Nodes.Add("A" & Rec.Fields("上级ID"), tvwChild, "B" & Rec.Fields("合同ID"), Rec.Fields("合同编号"))