老师您好!
我要分客户计算数据,由于客户比较多,将大客户单独列出计算,将小客户全归为其他客户,数据合并计算。我用了两种条件表达,但都不计算。我的代码:
第一种: Dim qth As String
qth="[客户]<>'abb' and [客户]<>'魏德曼' and [客户]<>'博瑞' and [客户]<>'博驰'and [客户]<>'望变'"
kgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='c '" & " And 发货日期 Is Not null")
kgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# " & qth & " And substring([ddlb],1,1)='z '" & " And 发货日期 Is Not null")
ylkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='c '")
ylkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='z '")
第二种:
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 '")
不知道什么原因不统计。请指教! 谢谢!