以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  查询中加入模糊查询  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=129337)

--  作者:青丘狐
--  发布时间:2018/12/26 14:41:00
--  查询中加入模糊查询

Dim Filter As String = ""
With e.Form.Controls("仓库")
    If .Value IsNot Nothing AndAlso .value <> "仓库" Then
        Filter = "仓库= \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("车船号")
    If .Value IsNot Nothing AndAlso .value <> "车船号" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "车船号 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("品种")
    If .Value IsNot Nothing AndAlso .value <> "品种" Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "品种 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("规格")
    If .Value IsNot Nothing AndAlso .value <> "规格" Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "规格 = \'" & .Value & "\'"
    End If
End With

 

With e.Form.Controls("钢种")
    If .Value IsNot Nothing AndAlso .value <> "钢种" Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "钢种 = \'" & .Value & "\'"
    End If
End With


With e.Form.Controls("原始提单信息")
    If .Value IsNot Nothing AndAlso .value <> "原始提单信息" Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = "原始提单信息 Like  \'%" & .Value & "%\'"
    End If
End With

With e.Form.Controls("提货车号")
    If .Value IsNot Nothing AndAlso .value <> "提货车号" Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = "提货车号 Like  \'%" & .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 Filter > "" Then
    Tables("仓库出库明细").Filter = Filter
End If

 

提货车号和原始提单信息加入模糊查询后,其他的就不能查询了,请问要怎样修改。


--  作者:青丘狐
--  发布时间:2018/12/26 15:23:00
--  

不能多条件一起查询


--  作者:青丘狐
--  发布时间:2018/12/26 15:43:00
--  
品种 钢种 规格 车船号 可以多选查询,加入提货车号,原始提单信息就不能多选查询了,提货车号,原始提单信息想用模糊查询。
[此贴子已经被作者于2018/12/26 15:44:38编辑过]

--  作者:有点甜
--  发布时间:2018/12/26 20:32:00
--  

Filter = "原始提单信息 Like  \'%" & .Value & "%\'"

 

改成

 

Filter = filter & "原始提单信息 Like  \'%" & .Value & "%\'"

 

----------------

 

Filter = "提货车号 Like  \'%" & .Value & "%\'"

 

改成

 

Filter = filter & "提货车号 Like  \'%" & .Value & "%\'"