Office中国论坛/Access中国论坛
标题: 那位大侠能帮我改一下这个treeview [打印本页]
作者: 6v87qe 时间: 2006-10-9 01:40
标题: 那位大侠能帮我改一下这个treeview
那位大侠能帮我改一下这个treeview,总是提示“mistype”
的错误提示,都改了好几天了,晕
Sub AddMyTree()
On Error GoTo Err_AddMyTree
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim nodCurrent As Node
Dim objTree As Object
Set objTree = Me.TreeView0
Set conn = CurrentProject.Connection
strSQL = "SELECT DISTINCT DateRec FROM FinalQuery GROUP BY DateRec;"
rst.Open strSQL, conn, adOpenStatic, adLockReadOnly
Dim nodeYear As Node
Dim nodeYearMonth As Node
Do While Not rst.EOF
Set nodeYear = Nothing
On Error Resume Next
Set nodeYear = objTree.Nodes _
("a" & Format(rst("DateRec").Value, "yyyy"))
On Error GoTo Err_AddMyTree
If nodeYear Is Nothing Then
Set nodeYear = objTree.Nodes _
.Add(, , "a" & Format(rst("DateRec").Value, "yyyy"), _
Format(rst("DateRec").Value, "yyyy"), 1, 2)
End If
Set nodeYearMonth = Nothing
On Error Resume Next
Set nodeYearMonth = objTree.Nodes _
("a" & Format(rst("DateRec").Value, "yyyymm"))
On Error GoTo Err_AddMyTree
If nodeYearMonth Is Nothing Then
Set nodeYearMonth = objTree.Nodes _
.Add(nodeYear, tvwChild, _
"a" & Format(rst("DateRec").Value, "yyyymm"), _
Format(rst("DateRec").Value, "mmmm"), 1, 2)
End If
Set nodCurrent = objTree.Nodes _
.Add(nodeYearMonth, tvwChild, _
"a" & rst("DateRec").Value, _
rst("DateRec").Value, 1, 2)
nodCurrent.Tag = rst.Fields("DateRec").Value
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set conn = Nothing
Exit_AddMyTree:
Exit Sub
Err_AddMyTree:
Set rst = Nothing
Set conn = Nothing
MsgBox Err.Description, vbCritical, "AddMyTree"
Resume Exit_AddMyTree
End Sub
Private Sub Detail_Click()
End Sub
Private Sub TreeView0_NodeClick(ByVal Node As Object)
Dim strSQL As String
strSQL = "SELECT * FROM FinalQuery "
strSQL = strSQL & "WHERE Daterec = #" & CDate(Node.Tag) & "# "
Me.FinalQuery_subform.Form.RecordSource = strSQL
Me.FinalQuery_subform.Form.Requery
End Sub
Private Sub Form_Load()
AddMyTree
End Sub
作者: fan0217 时间: 2006-10-10 16:38
传上例子来吧?
你顺便看看这个例子:[attach]20786[/attach]
[此贴子已经被作者于2006-10-10 9:27:24编辑过]
作者: 6v87qe 时间: 2006-10-11 03:18
例子传上来了,版主费心
[attach]20809[/attach]
[此贴子已经被作者于2006-10-10 19:19:47编辑过]
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) |
Powered by Discuz! X3.3 |