以文本方式查看主题

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

--  作者:swindy
--  发布时间:2019/8/13 14:24:00
--  筛选问题

Dim filter As String
Dim sts () As String = {"客户","订单号码","销售员","客户订单"}
For Each st As String In sts
    Dim val As String = e.Form.Controls(st).value
    If val > "" Then \'如果不是空
        Val = val.replace("*","[*]") \'把"*" 符号变成字符才能使用
        If filter = "" Then
            filter = st & " like \'*" & val & "*\'"
        Else
            filter = filter & " and " & st & " like \'*" & val & "*\'"
        End If
    End If
Next

Tables("订单明细表").Filter = Filter

 

1.增加“开始日期” 和 “结束日期”,以上模糊查询,代码怎样写?

 

 


图片点击可在新窗口打开查看此主题相关图片如下:2019-08-13.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2019/8/13 14:24:54编辑过]

--  作者:有点蓝
--  发布时间:2019/8/13 14:47:00
--  
这里日期使用模糊查询没有意义

Dim filter As String
Dim sts () As String = {"客户","订单号码","销售员","客户订单"}
For Each st As String In sts
    Dim val As String = e.Form.Controls(st).value
    If val > "" Then \'如果不是空
        Val = val.replace("*","[*]") \'把"*" 符号变成字符才能使用
        If filter = "" Then
            filter = st & " like \'*" & val & "*\'"
        Else
            filter = filter & " and " & st & " like \'*" & val & "*\'"
        End If
    End If
Next

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