Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
先根据组合框的内容进行筛选。再进行分组统计。
比如不进行筛选(组合框都为空),分组列是“乡名”,
比如筛选出了2007年的所有记录之后,分组列是“村名”“乡名”,
不要考虑造林类别和林种,请先做个例子出来
1、不选任何条件(组合框全为空)时统计各乡镇(列出乡名)各年度的合计值(不列出年度)分组列是“村名”“乡名”,
2、选择某个年度后列出该年度各乡镇的统计值。分组列是“乡名”,
3、选择某个年度某个乡镇后列出该年度该乡镇各村的统计值(列出村名)分组列是“村名”
4、不选取年度选某个乡镇后列出所有年度该乡镇各村的统计值(列出村名)分组列是“村名”“乡名”,
5、选择某个年度某个乡镇某个村列出该年度该乡镇该村的统计值分组列是“村名”
6、不选年度度选取某个乡镇某个村列出所有年度该乡镇该村的统计值,分组列是“村名”
非常感谢,太有创意!
Dim Filter As String
With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
Filter = "造林年度= '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "乡名= '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox3")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "村名 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "造林类别 = '" & .Value & "'"
End If
End With
With e.Form.Controls("ComboBox5")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "林种 = '" & .Value & "'"
End If
End With
'messagebox.show(Filter)
if Filter = "" then
Dim g As New GroupTableBuilder("统计表2", DataTables("总览"))
g.Groups.AddDef("乡名")
g.Groups.AddDef("村名")
g.Totals.AddDef("设计面积")
g.Build()
MainTable = Tables("统计表2")
ElseIf Filter.IndexOf("年度") <> -1 and Filter.IndexOf("乡名") = -1 then
Dim g As New GroupTableBuilder("统计表2", DataTables("总览"))
g.Groups.AddDef("乡名")
g.Totals.AddDef("设计面积")
g.Build()
MainTable = Tables("统计表2")
ElseIf Filter.IndexOf("年度") <> -1 and Filter.IndexOf("乡名") <> -1 then
Dim g As New GroupTableBuilder("统计表2", DataTables("总览"))
g.Groups.AddDef("村名")
g.Totals.AddDef("设计面积")
g.Build()
MainTable = Tables("统计表2")
else
messagebox.show(".....")
end if
'messagebox.show(Filter.IndexOf("乡名"))
谢谢回复!12楼的很好,你的还达不到目的,可在12楼的基础上进一步优化。
不错,顶
谢谢回复!12楼的很好,你的还达不到目的,可在12楼的基础上进一步优化。
呵..实现了就好..我只是提供一个条件判断的例子(我也只是在学习中...)