以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  筛选的问题?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=60248)

--  作者:jswjyjf
--  发布时间:2014/11/20 22:07:00
--  筛选的问题?


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

如上图 筛选代码 如下

 要求 如下:已审 未审 所有,这个所有 是指符合全面的条件 ,不知道怎么写

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

With e.Form.Controls("ckname")
    If .Value IsNot Nothing Then
        Filter = "仓库 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("khname")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 <= \'" & .Value & "\'"
    End If
End With
If e.Form.Controls("rdo1").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态=\'已审核\'"
End If
If e.Form.Controls("rdo2").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态<>\'已审核\' or 单据状态 is null"
End If
If Filter > "" Then
    Tables("销售单明细").Filter = Filter
End If
If Tables("销售单明细").rows.count=0
Tables("销售单明细").GrandTotal = False
Else
Tables("销售单明细").Cols("匹数").GrandTotal = True
Tables("销售单明细").Cols("米数").GrandTotal = True
Tables("销售单明细").GrandTotal = True \'显示合计模式
End If


 


--  作者:有点甜
--  发布时间:2014/11/20 22:11:00
--  

 所有是不用写的。

 

Dim Filter As String = "1=1"
With e.Form.Controls("pmname")
    If .Value IsNot Nothing Then
        Filter = " and 产品名称 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("ckname")
    If .Value IsNot Nothing Then
        Filter = " and 仓库 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("khname")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 <= \'" & .Value & "\'"
    End If
End With
If e.Form.Controls("rdo1").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态=\'已审核\'"
End If
If e.Form.Controls("rdo2").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态<>\'已审核\' or 单据状态 is null"
End If
Tables("销售单明细").Filter = Filter
If Tables("销售单明细").rows.count=0
    Tables("销售单明细").GrandTotal = False
Else
    Tables("销售单明细").Cols("匹数").GrandTotal = True
    Tables("销售单明细").Cols("米数").GrandTotal = True
    Tables("销售单明细").GrandTotal = True \'显示合计模式
End If


--  作者:jswjyjf
--  发布时间:2014/11/20 22:22:00
--  

出错了 选产品 其它不选 出错了


--  作者:有点甜
--  发布时间:2014/11/20 22:24:00
--  
 

Dim Filter As String = "1=1"
With e.Form.Controls("pmname")
    If .Value IsNot Nothing Then
        Filter &= " and 产品名称 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("ckname")
    If .Value IsNot Nothing Then
        Filter &= " and 仓库 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("khname")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "客户名称 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 >= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "销售日期 <= \'" & .Value & "\'"
    End If
End With
If e.Form.Controls("rdo1").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态=\'已审核\'"
End If
If e.Form.Controls("rdo2").Checked = True
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "单据状态<>\'已审核\' or 单据状态 is null"
End If
Tables("销售单明细").Filter = Filter
If Tables("销售单明细").rows.count=0
    Tables("销售单明细").GrandTotal = False
Else
    Tables("销售单明细").Cols("匹数").GrandTotal = True
    Tables("销售单明细").Cols("米数").GrandTotal = True
    Tables("销售单明细").GrandTotal = True \'显示合计模式
End If


--  作者:jswjyjf
--  发布时间:2014/11/20 22:25:00
--  

搞定了

多谢