以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  动态表达式  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=50240)

--  作者:阆子天涯
--  发布时间:2014/5/2 21:42:00
--  动态表达式

Dim Filter   As   String
With e.Form.Controls("品牌")
    If .Value   IsNot   Nothing  Then
        Filter =   "品牌 = \'" & .Value &   "\'"
    End   If
End   With

With e.Form.Controls("门店")
    If .Value   IsNot   Nothing   Then
        If Filter >""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "门店 = \'" & .Value &   "\'"
    End   If
End   With

With e.Form.Controls("年份")
    If .Value   IsNot   Nothing   Then
        If Filter > ""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "年份 = \'" & .Value &   "\'"
    End   If
End   With
With e.Form.Controls("季节")
    If .Value   IsNot   Nothing   Then
        If Filter >""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "季节 = \'" & .Value &   "\'"
    End   If
End   With

With e.Form.Controls("开始日期")
    If .Value   IsNot   Nothing   Then
        If Filter >""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "单据日期 >= #" & .Value &   "#"
    End   If
End   With
With e.Form.Controls("截止日期")
    If .Value   IsNot   Nothing   Then
        If Filter >""   Then
            Filter = Filter &   " And "
        End   If
        Filter = Filter &   "单据日期 <= #" & .Value &   "#"
    End   If
End   With

If   Filter >   "" Then
    Tables("出入库明细").Filter =   Filter
End If

Dim dt1,dt2 As DataTable
dt1=DataTables("出入库明细")
dt2=DataTables("库调明细表_主表")
Dim Arys As List(Of String())
Dim dr As  DataRow
Arys = DataTables("出入库明细").GetValues("编码|名称|颜色|尺码|年份|季节|零售价|款号",Filter)
For Each Ary As String() In Arys
    dr= DataTables("库存报表").addnew
    dr("编码")=Ary(0)
    dr("名称")=Ary(1)
    dr("颜色")=Ary(2)
    dr("尺码")=Ary(3)
    dr("年份")=Ary(4)
    dr("季节")=Ary(5)
    dr("零售价")=Ary(6)
Next

 

dr("库房_调拨出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'D\'and 收发类型= \'调拨出库\')
dr("店铺_调拨出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'R\'and 收发类型= \'调拨出库\')
dr("店铺_调拨入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'R\'and 收发类型= \'调拨入库\')
dr("库房_收货入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'F\'and 收发类型= \'收货入库\')
dr("库房_返货出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'T\'and 收发类型= \'返货出库\')

dr("店铺_零售出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And  收发类型= \'零售出库\')
dr("店铺_零退入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And  收发类型= \'零退入库\')


dr("店铺_库调")=dt2.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 收发类型= \'库调\')
dr("店铺_退货入库")=dt2.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'"  And  收发类型= \'退货入库\')


--  作者:阆子天涯
--  发布时间:2014/5/2 21:56:00
--  

请帮忙看下以下表达式哪儿错了,非常感谢!

 

 

dr("库房_调拨出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'D\'and 收发类型= \'调拨出库\')
dr("店铺_调拨出库")=dt1.Compute("s um(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'R\'and 收发类型= \'调拨出库\')
dr("店铺_调拨入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'R\'and 收发类型= \'调拨入库\')
dr("库房_收货入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'F\'and 收发类型= \'收货入库\')
dr("库房_返货出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 业务单号首位 = \'T\'and 收发类型= \'返货出库\')

dr("店铺_零售出库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And  收发类型= \'零售出库\')
dr("店铺_零退入库")=dt1.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And  收发类型= \'零退入库\')


dr("店铺_库调")=dt2.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'" And 收发类型= \'库调\')
dr("店铺_退货入库")=dt2.Compute("sum(数量)", Filter & " And 编码 = \'"& dr("编码") &"\'"  And  收发类型= \'退货入库\')


  单帖管理