Dim bd1 As New SQLCrossTableBuilder("统计1","订单明细表")
bd1.HGroups.AddDef("单位名称") '指定水平分组
bd1.VGroups.AddDef("收付") '指定垂直分组
bd1.Totals.AddDef("代收款")
bd1.Totals.AddDef("运费")
bd1.Totals.AddDef("办单费")
bd1.Totals.AddDef("提箱费")
bd1.Totals.AddDef("THC费")
bd1.Totals.AddDef("滞箱费")
bd1.Totals.AddDef("堆存费")
bd1.Totals.AddDef("其它费")
'bd1.Totals.AddExp("应付_金额","运费_1 + 办单费_1 + 提箱费_1 + THC费_1 + 滞箱费_1 + 堆存费_1 + 其它费_1 - 代收款_1")
bd1.Filter = "收付 = '应付'"
Tables(e.form.Name & "_统计表1").DataSource = bd1.BuildDataSource() '生成一个临时类
Tables(e.form.Name & "_统计表1").DataTable.DataCols.Add("金额_1",Gettype(Integer),70,"IsNull([运费_1],0) + IsNull([办单费_1],0) + IsNull([提箱费_1],0) + IsNull([THC费_1],0) + IsNull([滞箱费_1],0) + IsNull([堆存费_1],0) + IsNull([其它费_1],0) - IsNull([代收款_1],0) ","应付_金额")