以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请教修改代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102923)

--  作者:jamhuton
--  发布时间:2017/6/27 18:01:00
--  请教修改代码
If e.DataRow("商家名称") = "商家名称" Then
    e.DataRow("金额") = DataTables("船运明细").Compute("sum(金额)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("船运明细").Compute("sum(成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("船运明细").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
Else
    e.DataRow("金额") = DataTables("入库").Compute("sum(合计)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("入库").Compute("sum(装卸成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("入库").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
Else
    e.DataRow("金额") = DataTables("出库").Compute("sum(合计)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("出库").Compute("sum(运输成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("出库").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
End If

老师好,Else如何修改?
放一个else可以执行,放了2个代码需要变化吗?

--  作者:有点色
--  发布时间:2017/6/27 18:46:00
--  

参考

 

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

 


--  作者:jamhuton
--  发布时间:2017/6/28 9:45:00
--  
If e.DataRow("业务类型") = "业务类型" Then
    e.DataRow("金额") = DataTables("船运明细").Compute("sum(金额)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("船运明细").Compute("sum(成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("船运明细").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
ElseIf e.DataRow("业务类型") = "业务类型" Then
    e.DataRow("金额") = DataTables("入库").Compute("sum(合计)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("入库").Compute("sum(装卸成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("入库").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
Else
    e.DataRow("金额") = DataTables("出库").Compute("sum(合计)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("成本") = DataTables("出库").Compute("sum(运输成本)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
    e.DataRow("业务量") = DataTables("出库").Compute("count(箱型)","[商家名称]= \'" & e.DataRow("商家名称") & "\' And [月份]= \'" & e.DataRow("月份") & "\'And [业务类型]= \'" & e.DataRow("业务类型") & "\'" )
End If

第三段代码执行了,前面的不执行。

--  作者:jamhuton
--  发布时间:2017/6/28 9:59:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

从三个表格导入数据,前面的两个表格的数据没有导入。

--  作者:jamhuton
--  发布时间:2017/6/28 10:17:00
--  
找到问题了。