Dim bd1 As New SQLGroupTableBuilder("翻斗车汇总表","fdc")
Dim dt1 As fxDataSource
bd1.Groups.AddDef("ch") '对车号分组
bd1.Totals.AddDef("cs") '对车数进行统计
bd1.Totals.AddExp("je","cs * dj * Parent(b).fl","金额") '对金额进行统计
运行到上一句错
bd1.Filter="[rq] >= #" & Vars("mydate") & "# and [rq] <= #" & Vars("mydate1") & "# "
dt1 = bd1.BuildDataSource()
Dim bd2 As New SQLGroupTableBuilder("统计表2","jyb")
Dim dt2 As fxDataSource
bd2.Groups.AddDef("ch") '根据车号分组
bd2.Totals.AddDef("yl","柴油") '对柴油进行统计
bd2.Totals.AddExp("je","yl*dj","油款") '对油款进行统计
bd2.Filter="[rq] >= #" & Vars("mydate") & "# and [rq] <= #" & Vars("mydate1") & "# "
dt2 = bd2.BuildDataSource()
dt1.Combine("ch",dt2,"ch")
dt1.Show("翻斗车汇总表") '显示统计结果
Tables("翻斗车汇总表").Sort = "ch"
DataTables("翻斗车汇总表").DataCols("je").SetFormat ("0.00")
DataTables("翻斗车汇总表").DataCols("yl").SetFormat ("0")
DataTables("翻斗车汇总表").DataCols("金额").SetFormat ("0.00")
DataTables("翻斗车汇总表").DataCols.Add("应付款", Gettype(Single), "[je] - [金额]")
DataTables("翻斗车汇总表").DataCols("应付款").SetFormat ("0.00")
Tables("翻斗车汇总表").SetColVisibleWidth("ch|60|cs|60|je|80|yl|70|金额|80|应付款|80")
MainTable = Tables("翻斗车汇总表")
Dim t As Table = Tables("翻斗车汇总表")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = True
t.TreeVisible = True
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "cs,je,yl,金额,应付款"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()
[此贴子已经被作者于2012-4-6 21:06:31编辑过]