以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]多重全表模糊筛选  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=70957)

--  作者:46702888
--  发布时间:2015/7/2 10:34:00
--  [求助]多重全表模糊筛选
根据TextBox1文本框全表模糊筛选后,在此基础上再根据TextBox2文本框模糊筛选,并在此基础上根据TextBox3文本框模糊筛选,依此下去多个模糊筛选。代码如何写?如果有1000条记录,执行速度会很慢吗?

Dim filter As String = "1=2"
For Each dc As Col In CurrentTable.Cols
    filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & e.Form.Controls("TextBox1").Text & "%\'"
Next
CurrentTable.Filter = filter

[此贴子已经被作者于2015/7/2 10:51:32编辑过]

--  作者:大红袍
--  发布时间:2015/7/2 10:55:00
--  
Dim filter As String = "(1=2"
For Each dc As Col In CurrentTable.Cols
    filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & e.Form.Controls("TextBox1").Text & "%\'"
Next
filter = filter & ") and (1=2 "
For Each dc As Col In CurrentTable.Cols
    filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & e.Form.Controls("TextBox2").Text & "%\'"
Next
filter = filter & ") and (1=2 "
For Each dc As Col In CurrentTable.Cols
    filter &= " or convert(" & dc.Name & ",\'System.String\') like \'%" & e.Form.Controls("TextBox3").Text & "%\'"
Next
filter = filter & ")"
CurrentTable.Filter = filter

--  作者:jialihaha
--  发布时间:2015/7/2 11:05:00
--  
可以考虑做右键的筛选,我觉得很好用,而且做一次,以后想在哪筛选什么就筛选什么
--  作者:46702888
--  发布时间:2015/7/2 11:19:00
--  
谢谢大红袍老师!真的有很多基础要学习。也谢谢jialihaha,这个主意真的很受用!