我想生成如下统计表 应该如何做呢 我现在的做法是 增加一个表 然后 设置了如下代码 可是非常耗时
Dim dt As Table = Tables("表A")
dt.Filter="[类别]='服装' Or [类别]='木器'"
Dim s As Integer= dt.Rows.Count
dt.Filter="[类别]='服装'"
Dim a As Integer = dt.Rows.Count
dt.Filter="[类别]='木器'"
Dim b As Integer = dt.Rows.Count
dt.Filter="[种类]='医院' And [类别] <> '释放' And [类别] <> '调走'"
Dim c As Integer = dt.Rows.Count
dt.Filter = "[罪名] Like '*毒*' Or [罪名] Like '*枪*' Or [罪名] Like '黑社会'"
Dim d As Integer = dt.Rows.Count
dt.Filter = "[犯罪类型] = '财产型' And [类别] <> '释放' And [类别] <> '调走'"
Dim n As Integer = dt.Rows.Count
dt.Filter = "[犯罪类型] = '暴力型' And [类别] <> '释放' And [类别] <> '调走'"
Dim f As Integer = dt.Rows.Count
dt.Filter = "[犯罪类型] = '淫欲型' And [类别] <> '释放' And [类别] <> '调走'"
Dim t As Integer = dt.Rows.Count
dt.Filter = "[罪名] Like '*职务*' Or [罪名] Like '*贪污*' Or [罪名] Like '挪用'"
Dim y As Integer = dt.Rows.Count
dt.Filter = "[处遇级别] = '一级严管' And [类别] <> '释放' And [类别] <> '调走'"
Dim q As Integer = dt.Rows.Count
dt.Filter = "[处遇级别] = '二级严管' And [类别] <> '释放' And [类别] <> '调走'"
Dim w As Integer = dt.Rows.Count
dt.Filter = "[处遇级别] = '普管' And [类别] <> '释放' And [类别] <> '调走'"
Dim i As Integer = dt.Rows.Count
dt.Filter = "[处遇级别] = '二级宽管' And [类别] <> '释放' And [类别] <> '调走'"
Dim o As Integer = dt.Rows.Count
Dim p As Integer = Date.Today.Year
Dim dt1 As New Date(p, 1, 1)
Dim dt2 As New Date(p, 12, 31)
Dim dt3 As Table = Tables("调动明细表")
dt3.Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "# And [调动类型] = '调入'"
Dim s1 As Integer = dt3.Rows.Count
dt3.Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "# And [调动类型] = '调出'"
Dim s5 As Integer = dt3.Rows.Count
dt3.Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "# And [调动类型] = '转监狱'"
Dim s6 As Integer = dt3.Rows.Count
Dim dt5 As New Date(2013, 1, 1)
Dim dt6 As New Date(2013, 12, 31)
dt3.Filter = "日期 >= #" & dt5 & "# And 日期 <= #" & dt6 & "# And [调动类型] = '调入'"
Dim s2 As Integer = dt3.Rows.Count
dt3.Filter = "日期 >= #" & dt5 & "# And 日期 <= #" & dt6 & "# And [调动类型] = '调出'"
Dim s3 As Integer = dt3.Rows.Count
dt3.Filter = "日期 >= #" & dt5 & "# And 日期 <= #" & dt6 & "# And [调动类型] = '转监狱'"
Dim s4 As Integer = dt3.Rows.Count
If e.DataRow("统计项目")="全体在册人数" Then
e.DataRow("统计值")= s & "人"
ElseIf e.DataRow("统计项目")="服装在册人数" Then
e.DataRow("统计值")= a & "人"
e.DataRow("环比")= "占总人数比例为" & Format(a/s,"00.0%")
ElseIf e.DataRow("统计项目")="木器在册人数" Then
e.DataRow("统计值")= b & "人"
e.DataRow("环比")= "占总人数比例为" & Format(b/s,"00.0%")
ElseIf e.DataRow("统计项目")="住院人数" Then
e.DataRow("统计值")= c & "人"
ElseIf e.DataRow("统计项目")="三涉人员人数" Then
e.DataRow("统计值")= d & "人"
e.DataRow("环比")= "占总人数比例为" & Format(d/s,"00.0%")
ElseIf e.DataRow("统计项目")="财产型罪犯" Then
e.DataRow("统计值")= n & "人"
e.DataRow("环比")= "占总人数比例为" & Format(n/s,"00.0%")
ElseIf e.DataRow("统计项目")="暴力型罪犯" Then
e.DataRow("统计值")= f & "人"
e.DataRow("环比")= "占总人数比例为" & Format(f/s,"00.0%")
ElseIf e.DataRow("统计项目")="淫欲型罪犯" Then
e.DataRow("统计值")= t & "人"
e.DataRow("环比")= "占总人数比例为" & Format(t/s,"00.0%")
ElseIf e.DataRow("统计项目")="职务类罪犯" Then
e.DataRow("统计值")= y & "人"
e.DataRow("环比")= "占总人数比例为" & Format(y/s,"00.0%")
ElseIf e.DataRow("统计项目")="一级严管" Then
e.DataRow("统计值")= q & "人"
e.DataRow("环比")= "占总人数比例为" & Format(q/s,"00.0%")
ElseIf e.DataRow("统计项目")="二级严管" Then
e.DataRow("统计值")= w & "人"
e.DataRow("环比")= "占总人数比例为" & Format(w/s,"00.0%")
ElseIf e.DataRow("统计项目")="普管" Then
e.DataRow("统计值")= i & "人"
e.DataRow("环比")= "占总人数比例为" & Format(i/s,"00.0%")
ElseIf e.DataRow("统计项目")="二级宽管" Then
e.DataRow("统计值")= o & "人"
e.DataRow("环比")= "占总人数比例为" & Format(o/s,"00.0%")
ElseIf e.DataRow("统计项目")="当年调入人数" Then
e.DataRow("统计值")= s1 & "人"
ElseIf e.DataRow("统计项目")="2013年调入人数" Then
e.DataRow("统计值")= s2 & "人"
ElseIf e.DataRow("统计项目")="2013年调出人数" Then
e.DataRow("统计值")= s3 & "人"
ElseIf e.DataRow("统计项目")="2013年转监狱人数" Then
e.DataRow("统计值")= s4 & "人"
ElseIf e.DataRow("统计项目")="当年调出人数" Then
e.DataRow("统计值")= s5 & "人"
ElseIf e.DataRow("统计项目")="当年转监狱人数" Then
e.DataRow("统计值")= s6 & "人"
End If
此主题相关图片如下:4.jpg