以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  选择按姓名汇总考核分数,为什么不汇总呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=28713)

--  作者:chenjiu6202
--  发布时间:2013/2/15 19:51:00
--  选择按姓名汇总考核分数,为什么不汇总呢?
 
 

--  作者:chenjiu6202
--  发布时间:2013/2/15 20:09:00
--  

Dim qs As WinForm.DateTimePicker = e.Form.Controls("起始日期1")
Dim zz As WinForm.DateTimePicker = e.Form.Controls("终止日期1")
Dim tj1 As WinForm.ComboBox = e.Form.Controls("统计1")
Dim tj2 As WinForm.ComboBox = e.Form.Controls("统计2")


图片点击可在新窗口打开查看此主题相关图片如下:q`zws9li%aq%}lnjzf@n_e.jpg
图片点击可在新窗口打开查看

If e.Form.Controls("终止日期1").Value < e.Form.Controls("起始日期1").Value Then
MessageBox.Show("请重新选择日期")
e.Form.Controls("终止日期1").Value = Nothing
e.Form.Controls("终止日期1").Select
e.Form.Controls("起始日期1").Value = Nothing
End If

If  e.Form.Controls("统计1").Value = Nothing
MessageBox.Show("请重新选择分组统计")
End If

Dim t As Table = Tables("奖惩考核表")
Dim g As Subtotalgroup
Dim Val As String = Forms("数据汇总").Controls("统计1").Value


t.Filter = "[日期] <= #" & e.form.Controls("终止日期1").Value & "# and [日期] >= #" & e.form.Controls("起始日期1").Value & "#"
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True

 

g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = val
g.TotalOn = "考核分数"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal()\'

Dim r As Row


For i As Integer = 0 To t.Rows.Count(True) - 1
    r = t.Rows(i,True)
    If r.IsGroup \'如果是分组行
        Dim f As String = "" & val & " = \'" & r(val) & "\'"
        Dim v As String = " 违章件数:" & t.Compute("Count(代号)",f)
        v = v & " 考核分数:" & t.Compute("Sum(考核分数)",f)
        \'v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
        r("违章条例") = "统计项目:" & val & v
    End If
Next


图片点击可在新窗口打开查看此主题相关图片如下:8@mwg(`tj%o%{k)bo`w1opc.jpg
图片点击可在新窗口打开查看

--  作者:chenjiu6202
--  发布时间:2013/2/15 20:17:00
--  

如果菜单选择代号时,代码汇总,选择姓名时,不汇总。


--  作者:lin_hailun
--  发布时间:2013/2/16 9:46:00
--  
 看了下代码,好像没有错。也不会出现不汇总的情况。

 汇总条件应该有些问题。你msgbox看看,加入下面红色代码,截图看看,注意空格。如果条件正常,只能是你的数据表多或者少一个空格的缘故了。

  If r.IsGroup \'如果是分组行
        Dim f As String = val & " = \'" & r(val) & "\'"
msgbox(f)
        Dim v As String = " 违章件数:" & t.Compute("Count(代号)",f)
        v = v & " 考核分数:" & t.Compute("Sum(考核分数)",f)
        \'v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
        r("违章条例") = "统计项目:" & val & v
    End If
[此贴子已经被作者于2013-2-16 9:45:58编辑过]