设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1547|回复: 2
打印 上一主题 下一主题

[与其它组件] 那位大侠能帮我改一下这个treeview

[复制链接]
跳转到指定楼层
1#
发表于 2006-10-9 01:40:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
那位大侠能帮我改一下这个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

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2006-10-10 16:38:00 | 只看该作者
传上例子来吧?

你顺便看看这个例子:


[此贴子已经被作者于2006-10-10 9:27:24编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
3#
 楼主| 发表于 2006-10-11 03:18:00 | 只看该作者
例子传上来了,版主费心



[此贴子已经被作者于2006-10-10 19:19:47编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-6-7 22:49 , Processed in 0.087637 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表