Foxtable(狐表)用户栏目专家坐堂 → 筛选问题


  共有2459人关注过本帖树形打印复制链接

主题:筛选问题

帅哥哟,离线,有人找我吗?
swindy
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:156 积分:1317 威望:0 精华:0 注册:2017/8/11 16:01:00
筛选问题  发帖心情 Post By: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编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110581 积分:562801 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By: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
……

 回到顶部