以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动汇总  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88437)

--  作者:kaituozhe
--  发布时间:2016/8/3 0:50:00
--  自动汇总

Dim filter As String = "科目编号 = \'" & e.DataRow("科目编号") & "\'and  项目编号 = \'" & e.DataRow("项目编号") & "\'and 日期 >= \'" & e.DataRow("开始日期") & "\'and 日期 <= \'" & e.DataRow("截止日期") & "\'and 公司名称 = \'" & e.DataRow("公司名称") & "\'"
\'Dim filter As String = "科目编号 = \'" & e.DataRow("科目编号") & "\'And 日期 >= \'" & e.DataRow("开始日期") & "\'and 日期 <= \'" & e.DataRow("截止日期") & "\'and 公司名称 = \'" & e.DataRow("公司名称") & "\'"


Select Case e.DataCol.name
    Case "开始日期"
        e.DataRow("发生借方") = DataTables("凭证明细").Compute("sum(借方金额)",filter)
        e.DataRow("发生贷方") = DataTables("凭证明细").Compute("sum(贷方金额)",filter)
       
End Select

 

以上代码中 科目编号 项目编号 开始日期 截止日期 四项必须都不为空时计算才有效,有一项是空时计算无效,怎么改进呀,能其中某一、两项空时还有效。


--  作者:大红袍
--  发布时间:2016/8/3 9:24:00
--  

判断是否为空,再合成filter,类似

 

http://www.foxtable.com/webhelp/scr/1058.htm