以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]统计 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=113366) |
-- 作者:江南小镇 -- 发布时间:2018/1/14 22:06:00 -- [求助]统计 老师,下面代码有什么地方不对吗? If e.DataCol.name = "年份" OrElse e.DataCol.name = "来源" OrElse e.DataCol.name = "商品名称" Then If e.DataRow.Isnull("年份") = False AndAlso e.DataRow.Isnull("来源") =False AndAlso e.DataRow.Isnull("商品名称") = False Then Dim filter1 As String = "来源 = \'" & e.DataRow("来源") & "\'" Dim filter2 As String = "来源 = \'" & e.DataRow("来源") & "\'" For i As Integer = 1 To 12 Dim d As Date = new Date(val(e.DataRow("年份")), i, 1) Dim sum As Integer = DataTables("进销存").compute("sum(出库_金额)", filter1 & " and 日期 >= #" & d & "# and 日期 < #" & d.addmonths(1) & "#") Dim sum1 As Integer = DataTables("进销存").compute("sum(入库_金额)", filter2 & " and 日期 >= #" & d & "# and 日期 < #" & d.addmonths(1) & "#") \'e.DataRow("M" & i) = sum e.DataRow("M" & i) = sum + sum1 Next Else For i As Integer = 1 To 12 e.DataRow("M" & i) = Nothing Next End If End If
|
-- 作者:有点甜 -- 发布时间:2018/1/14 22:15:00 -- 报错还是怎样,请具体说明。
截图或者实例说明一下。 |
-- 作者:江南小镇 -- 发布时间:2018/1/16 18:28:00 -- 老师,我想把代码修改成只统计当年度的。 If e.DataCol.name = "年份" OrElse e.DataCol.name = "项目_类别" OrElse e.DataCol.name = "项目_明细" Then If e.DataRow.Isnull("年份") = False AndAlso e.DataRow.Isnull("项目类别") =False AndAlso e.DataRow.Isnull("项目明细") = False Then Dim filter1 As String = "项目_类别 = \'" & e.DataRow("项目类别") & "\'" For i As Integer = 1 To 12 Dim d As Date = new Date(val(e.DataRow("年份")), i, 1) Dim sum As Integer = DataTables("支出明细").compute("sum(支出_金额)", filter1 & " and 记录日期 >= #" & d & "# and 记录日期< #" & d.addmonths(1) & "#") e.DataRow("M" & i) = sum Next Else For i As Integer = 1 To 12 e.DataRow("M" & i) = Nothing Next End If End If
|
-- 作者:有点甜 -- 发布时间:2018/1/16 18:31:00 -- 现在有什么问题?你代码统计的数据,就是当年、1-12月的数据啊。 |
-- 作者:江南小镇 -- 发布时间:2018/1/16 18:39:00 -- 老师,17年的也能统计,我要统计18年度 |
-- 作者:有点蓝 -- 发布时间:2018/1/16 20:27:00 -- 你年份列记录的是哪一年就统计的哪一年的 |
-- 作者:江南小镇 -- 发布时间:2018/1/16 21:37:00 -- 老师,年份有16年有17年有18年的我想只统计本年度的也就是18年的。 |
-- 作者:有点蓝 -- 发布时间:2018/1/16 21:47:00 -- 看不懂你的问题,截图说明 |
-- 作者:江南小镇 -- 发布时间:2018/1/16 21:56:00 -- 在支出明细表中筛选出本年度的数据然后再统计 |
-- 作者:有点蓝 -- 发布时间:2018/1/16 22:09:00 -- 截图,或者上传实例说明 |