以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  数据替换填充  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160327)

--  作者:朱女士
--  发布时间:2021/1/29 9:34:00
--  数据替换填充

老师您好!

      我今天的问题与昨天的问题类似。有个数据表分类型统计,可是我统计完毕后数据准确,但填充不到表中。我是用客户名称作为字段名,将大客户数据单独列出,将其他小客户归类为其他。代码和表界面如下:

    If wr("二级代码")="a020"
        \' 原料费用之累计和选月合计费用, 按实际发生
        For Each km As String In kms
            \'大客户累计层压木纸板原料
           
            ylkje1= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# and [客户]=\'" & km & "\'And substring([ddlb],1,1)=\'c \'")
            ylkje2= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# and [客户]=\'" & km & "\'And substring([ddlb],1,1)=\'z \'")
            zd1=km+z1
            zd2=km+z2
            zd3=km+z3
            zd4=km+z4
            zd5=km+z5
            wr(zd1)=ylkje1
            wr(zd2)=ylkje2
            kgh1= Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# and [客户]=\'" &  km & "\'And substring([ddlb],1,1)=\'c \'" & " And 发货日期 Is Not null")
            kgh2= Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# and [客户]=\'" &  km & "\'And substring([ddlb],1,1)=\'z \'" & " And 发货日期 Is Not null")
            wr(zd3)=ylkje1/kgh1
            wr(zd4)=ylkje2/kgh2
            wr(zd5)=ylkje1+ylkje2
            \'\'选月
            xkje1= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt1 & "# And [ckdate]<= #" & dt2 & "# and [客户]=\'" & km & "\'And substring([ddlb],1,1)=\'c \'")
            xkje2= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt1 & "# And [ckdate]<= #" & dt2 & "# and [客户]=\'" & km & "\'And substring([ddlb],1,1)=\'z \'")
           
            xkgh1= Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt1 & "# And [发货日期]<= #" & dt2 & "# and [客户]=\'" &  km & "\'And substring([ddlb],1,1)=\'c \'" & " And 发货日期 Is Not null")
            xkgh2= Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt1 & "# And [发货日期]<= #" & dt2 & "# and [客户]=\'" &  km & "\'And substring([ddlb],1,1)=\'z \'" & " And 发货日期 Is Not null")
           
            xzd1=km+xz1
            xzd2=km+xz2
            xzd3=km+xz3
            xzd4=km+xz4
            xzd5=km+xz5
            wr(xzd1)=xkje1
            wr(xzd2)=xkje2
            wr(xzd3)=xkje1/xkgh1
            wr(xzd4)=xkje2/xkgh2
            wr(xzd5)=xkje1+xkje2
        Next
       
        \'其他客户为大客户之外的小客户均为其他
        \'\'累计
        \'Dim qth As String
        \'qth="[客户]<>\'abb\' and [客户]<>\'魏德曼\' and [客户]<>\'博瑞\' and [客户]<>\'博驰\'and [客户]<>\'望变\'"
        kgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'" & "And 发货日期 Is Not null")
        kgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'" & "And 发货日期 Is Not null")
        ylkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'")
        ylkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'")
             
              
        \'\'选月
        xkgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt1 & "# And [发货日期]<= #" & dt2 & "# and [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c \'" & " And 发货日期 Is Not null")
        xkgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt1 & "# And [发货日期]<= #" & dt2 & "# and [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z \'" & " And 发货日期 Is Not null")
       
        xkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt1 & "# And [ckdate]<= #" & dt2 & "# and [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c \'")
        xkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt1 & "# And [ckdate]<= #" & dt2 & "# and [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z \'")
        wr(qzd1)=ylkje3
        wr(qzd2)=ylkje4
        wr(qzd3)=ylkje3/kgh3
        wr(qzd4)=ylkje4/kgh4
        wr(qzd5)=ylkje3+ylkje4
    
        wr(qxzd1)=xkje3
        wr(qxzd2)=xkje4
        wr(qxzd3)=xkje3/xkgh3
        wr(qxzd4)=xkje4/xkgh4
        wr(qxzd5)=xkje3+xkje4
    End If
 

表界面的二级代码:“a020”行,“a040”行和"a060"行,其他累计数据和选月其他数据就是填充不上。

  我找一天原因也没找到。谢谢指教!


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

--  作者:有点蓝
--  发布时间:2021/1/29 9:43:00
--  
和昨天一样的调试方法,有没有加载了符合条件的数据?
--  作者:朱女士
--  发布时间:2021/1/29 9:44:00
--  
我用了昨天的测试方式,测试有数据。
--  作者:朱女士
--  发布时间:2021/1/29 9:45:00
--  
我在迷茫
--  作者:有点蓝
--  发布时间:2021/1/29 9:48:00
--  
请上传实例测试
--  作者:有点蓝
--  发布时间:2021/1/29 9:50:00
--  
改为datatable试试,table会受筛选影响,筛选掉的数据是不会计算的

datatable("ddpsb").Compute

--  作者:朱女士
--  发布时间:2021/1/29 10:02:00
--  


此主题相关图片如下:界面2.png
按此在新窗口浏览图片


     代码: wr(qzd1)=ylkje3
messagebox.show(wr(qzd1))


--  作者:有点蓝
--  发布时间:2021/1/29 10:03:00
--  
贴出完整代码!
--  作者:朱女士
--  发布时间:2021/1/29 10:41:00
--  

完整代码,计算数据准确,不是所有的不替换填充,只有二级代码: a020,a040,a060行的其他用户的累计和选月的数据不填充。别的数据都对。代码太长我压缩了。

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:完整代码.zip


--  作者:有点蓝
--  发布时间:2021/1/29 10:53:00
--  

msgbox("[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'" & "And 发货日期 Is Not null")

       kgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'" & "And 发货日期 Is Not null")

msgbox("[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'" & "And 发货日期 Is Not null")

msgbox(kgh4)

        kgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'" & "And 发货日期 Is Not null")

msgbox("[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'")

msgbox(ylkje3)

        ylkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'c\'")

msgbox("[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'")

msgbox(ylkje4)

        ylkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# And [客户] Not In (\'abb\',\'魏德曼\',\'博瑞\',\'博驰\',\'望变\') And substring([ddlb],1,1)=\'z\'")