Dim shengrs As ADODB.Recordset Dim shirs As ADODB.Recordset Dim xianjirs As ADODB.Recordset
Set shengrs = New ADODB.Recordset shengrs.CursorLocation = adUseClient shengrs.Open "select sheng,id from sheng ORDER BY id ", CurrentProject.Connection, 1 If shengrs.RecordCount > 0 Then shengrs.MoveFirst Do While shengrs.EOF = False Set mnode1 = TreeView0.Nodes.Add(, , shengrs.Fields("sheng"), shengrs.Fields("sheng")) Set shirs = New ADODB.Recordset shirs.CursorLocation = adUseClient shirs.Open "select shi,id ,shengid from shi ORDER BY id ", CurrentProject.Connection, 1 shirs.MoveFirst Do While shirs.EOF = False If shirs.Fields("shengid") = shengrs.Fields("id") Then Set mnode2 = TreeView0.Nodes.Add(mnode1.Key, tvwChild, shirs.Fields("shi"), shirs.Fields("shi")) End If Set xianrs = New ADODB.Recordset xianrs.CursorLocation = adUseClient xianrs.Open "select xian,id,shiid from xian ORDER BY id ", CurrentProject.Connection, 1 xianrs.MoveFirst Do While xianrs.EOF = False If xianrs.Fields("shiid") = shirs.Fields("id") Then Set mnode3 = TreeView0.Nodes.Add(mnode2.Key, tvwChild, , xianrs.Fields("xian")) End If xianrs.MoveNext Loop shirs.MoveNext Loop shengrs.MoveNext Loop End If
End Sub