Dim s1,s2,s3,sql As String
For Each s1 In "类型,生产线,品种".split(",")
If Forms("窗口1").Controls(s1).checked = True Then
s2 + = "," & s1
s3 + = "|" & s1
End If
Next
sql ="SELECT DISTINCT Year(日期) As 年, Month(日期) As 月 " & s2 & " F rom {表A}"
Dim cmd As New SQLCommand
'cmd.C
Dim dt As DataTable
cmd.CommandText = sql
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = Forms("窗口1").Controls("TreeView1")
trv.BuildTree(dt, "年|月" & s3)
[此贴子已经被作者于2015/5/19 13:52:39编辑过]