Foxtable(狐表)用户栏目专家坐堂 → 自动计算


  共有2018人关注过本帖树形打印复制链接

主题:自动计算

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/1/20 14:28:00 [显示全部帖子]

Forms("查询").open
Dim sql As String = "Select 项目,金额,期间,收入明细,部门编号 FROM {门诊收入预算} where (收入明细 not like '总计'  or 收入明细 is null) and (收入明细 not like '%合计%' or 收入明细 is null) and 项目 is not null union all Select 项目,金额,'小计',收入明细,部门编号 FROM {门诊收入预算} where (收入明细 not like '总计'  or 收入明细 is null) and (收入明细 not like '%合计%' or 收入明细 is null) and 项目 is not null " 
Dim b As New CrossTableBuilder("统计表1",sql) 
b.HGroups.AddDef("项目")
b.vGroups.AddDef("部门编号")
b.VGroups.AddDef("期间","{0}月")
b.Totals.AddDef("金额") 
b.HorizontalTotal = True
b.VerticalTotal = True
b.Build()
For Each dr As DataRow In DataTables("统计表1").DataRows
    Dim sum As Double = 0
    For Each c As DataCol In DataTables("统计表1").DataCols
        If c.Caption Like "*小计*" Then sum += dr(c.Name)
    Next
    dr("合计") = sum
Next
Forms("查询").controls("table1").Table.DataSource = DataTables("统计表1")

 回到顶部