我查看了几个关于树的代码,
发现有一个"a"
不知在此代码中 a 代表什么?
________________
请讲一下好吗:
Option Compare Database
Option Explicit
Dim r As DAO.Recordset
Private Sub Form_Load()
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim nodCurrent As Node
Dim nodRoot As Node
Dim bk As String
Dim t As TreeView
DoCmd.Maximize
Set rst = CurrentDb.OpenRecordset("tab类别", dbOpenDynaset, dbReadOnly)
rst.FindFirst "[上级ID] Is Null"
Set t = treTrView.Object
Do Until rst.NoMatch
Set nodCurrent = t.Nodes.Add(, , "a" & rst!id, rst![类别], 7, 8)
bk = rst.Bookmark
AddChildren nodCurrent, rst
rst.Bookmark = bk
rst.FindNext "[上级ID] Is Null"
Loop
ClearTemp
lst问列表.Requery
End Sub
Sub AddChildren(nodBoss As Node, rst As DAO.Recordset)
Dim nodCurrent As Node
Dim bk As String
rst.FindFirst "[上级ID] =" & Mid(nodBoss.key, 2)
Do Until rst.NoMatch
Set nodCurrent = treTrView.Nodes.Add(nodBoss, tvwChild, "a" & rst!id, rst![类别], 1, 8)
bk = rst.Bookmark
AddChildren nodCurrent, rst
rst.Bookmark = bk
rst.FindNext "[上级ID]=" & Mid(nodBoss.key, 2)
Loop
End Sub
Private Sub Form_Resize()
DoCmd.Maximize
End Sub
Private Sub Form_Timer()
labDateTime.Caption = Now
End Sub
Private Sub labDateTime_Click()
End Sub
Private Sub lst问列表_Click()
Dim s As String
s = Nz(DLookup("例", "tabData", "[ID] =" & lst问列表.Value))
If s <> "" Then
lab例.Caption = CurrentProject.Path + "\DATA\" + _
treTrView.Nodes("a" & DLookup("类别ID", "tabData", "[ID]= " & lst问列表.Value)).FullPath _
+ "\" + s
Else
lab例.Caption = ""
End If
lab例.HyperlinkAddress = lab例.Caption
End Sub
Private Sub treTrView_NodeClick(ByVal Node As Object)
ClearTemp
Set r = CurrentDb.OpenRecordset("tabTemp")
Add Node
r.Close
lst问列表.Requery
End Sub
Private Sub ClearTemp()
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE tabTemp.* FROM tabTemp;"
End Sub
Private Sub Add(n As Node)
r.AddNew
r![IDTemp] = Val(Mid(n.key, 2))
r.Update
If n.Children > 0 Then Add n.Child
If Not (n.Next Is Nothing) And n.key <> treTrView.SelectedItem.key Then Add n.Next
End Sub
[此贴子已经被作者于2003-11-12 22:38:54编辑过]
|