以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  筛选出错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=32319)

--  作者:nand
--  发布时间:2013/4/29 12:41: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 &" = True "
    End If
End With

If Filter > "" Then
    Tables("订单排产_订单表").Filter = Filter
End If

报错是:


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

请师傅、师兄们指点


--  作者:nand
--  发布时间:2013/4/29 12:50:00
--  

发现原因了,是我用了逻辑列去和字符串做筛选


--  作者:nand
--  发布时间:2013/4/29 12:59:00
--  

With e.Form.Controls("部门")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & ""&.value &" = True "
    End If
End With

 

这段代码是逻辑型的,我应该要怎么改呢?


--  作者:don
--  发布时间:2013/4/29 13:14:00
--  
With e.Form.Controls("部门")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "部门  = True"
    End If
End With