|
我在根据咱们网友的作品研究TREEVIEW,第二层NODE 为什么只添加最后一项呢?
Private Sub Form_Open(Cancel As Integer)
Dim sydb As DAO.Database, reccx1 As DAO.Recordset, reccx2 As DAO.Recordset
Dim reccx3 As DAO.Recordset, reccx4 As DAO.Recordset
Dim strgjid As String, strgjname As String
Dim strssid As String, strssname As String
Dim strsxid As String, strsxname As String
Dim strkhid As String, strkhname As String
Dim strcxid As String, strtj As String
Dim mnode As Node ' 节点
Set sydb = CurrentDb()
xx.Visible = True 'xx 窗体标签控件
'''''''''''''''''''''''''''''''''''''''''''''''''
Set reccx1 = sydb.OpenRecordset("SELECT DISTINCT Left([地区代号],2) AS 国家代号,地区清单表.[国家/地区] FROM 地区清单表;")
With reccx1
.MoveLast
.MoveFirst
End With
Do While Not reccx1.EOF()
strgjid = reccx1("国家代号")
strgjname = reccx1("国家/地区")
Set mnode = TreeView1.Nodes.Add(, , "NO" & strgjid, strgjname)
'xx.Caption = "正在添加:" & mnode.Text
reccx1.MoveNext
Loop
''''''''''''''''''''''''''''''''''''''''''''''''
Set reccx2 = sydb.OpenRecordset("SELECT DISTINCT Left([地区代号],2) as 国家代号,left([地区代号],4) AS 省市代号, 地区清单表.[省/市/自治区] FROM 地区清单表 WHERE ((Left([地区代号],2) =" & strgjid & "));")
With reccx2
.MoveLast
.MoveFirst
End With
'增加省NODES
Do While Not reccx2.EOF()
strgjid = reccx2("国家代号")
strssid = reccx2("省市代号") '必须放在循环内
strssname = reccx2("省/市/自治区")
Set mnode = TreeView1.Nodes.Add("NO" & strgjid, tvwChild, "NO" & strssid, strssname)
reccx2.MoveNext
Loop
............................. |
|