以文本方式查看主题

-  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=37740)

--  作者:seal51
--  发布时间:2013/7/10 0:12:00
--  [求助]模糊查询

Dim cpth As WinForm.TextBox = e.Form.Controls("产品图号")
Dim zwmc As WinForm.TextBox = e.Form.Controls("中文名称")
Dim zwcl As WinForm.TextBox = e.Form.Controls("中文材料")
Dim zwgg As WinForm.TextBox = e.Form.Controls("中文规格")

Tables("产品").Filter="产品图号 like \'*" & cpth.Value & "*\' and 中文名称 like \'*" & zwmc.Value & "*\' and 中文材料 like \'*" & zwcl.Value & "*\' and 中文规格 like \'*" & zwgg.Value & "*\'"

 

 

建立了四个文本框,每个文本框单独模糊查询, 代码如上!, 但每次查询一个后, 按全部显示, 再重新查询其他三个文本框却无任何数据, 问题出在哪里呢, 请大家指教!


--  作者:程兴刚
--  发布时间:2013/7/10 0:24:00
--  

Dim cpth As String = e.Form.Controls("产品图号").Value
Dim zwmc As String = e.Form.Controls("中文名称").Value
Dim zwcl As String = e.Form.Controls("中文材料").Value
Dim zwgg As String = e.Form.Controls("中文规格").Value
Dim Filter As String
If cpth <> ""
    Filter = "产品图号 like \'*" & cpth & "*\'"
End If
If zwmc <> ""
    If Filter = ""
        Filter = "中文名称 like \'*" & zwmc & "*\'"
    Else
        Filter = Filter & " and 中文名称 Like \'*" & zwmc & "*\'"
    End If
End If
If zwcl <> ""
    If Filter = ""
        Filter = "中文材料 like \'*" & zwcl & "*\'"
    Else
        Filter = Filter & " and 中文材料 Like \'*" & zwcl & "*\'"
    End If
End If
If zwgg <> ""
    If Filter = ""
        Filter = "中文规格 like \'*" & zwgg & "*\'"
    Else
        Filter = Filter & " and 中文规格 Like \'*" & zwgg & "*\'"
    End If
End If
Tables("产品").Filter =Filter


--  作者:seal51
--  发布时间:2013/7/10 0:30:00
--  

谢谢老师的回复!不过,试了一下, 结果一样??


--  作者:seal51
--  发布时间:2013/7/10 0:32:00
--  
比如查询产品图号, 显示出几行数据, 清空后,查询产品名称, 无任何数据?
--  作者:程兴刚
--  发布时间:2013/7/10 0:45:00
--  

Tables("产品").Filter = ""

Dim cpth As String = e.Form.Controls("产品图号").Value
Dim zwmc As String = e.Form.Controls("中文名称").Value
Dim zwcl As String = e.Form.Controls("中文材料").Value
Dim zwgg As String = e.Form.Controls("中文规格").Value
Dim Filter As String
If cpth <> ""
    Filter = "产品图号 like \'*" & cpth & "*\'"
End If
If zwmc <> ""
    If Filter = ""
        Filter = "中文名称 like \'*" & zwmc & "*\'"
    Else
        Filter = Filter & " and 中文名称 Like \'*" & zwmc & "*\'"
    End If
End If
If zwcl <> ""
    If Filter = ""
        Filter = "中文材料 like \'*" & zwcl & "*\'"
    Else
        Filter = Filter & " and 中文材料 Like \'*" & zwcl & "*\'"
    End If
End If
If zwgg <> ""
    If Filter = ""
        Filter = "中文规格 like \'*" & zwgg & "*\'"
    Else
        Filter = Filter & " and 中文规格 Like \'*" & zwgg & "*\'"
    End If
End If
Tables("产品").Filter =Filter


--  作者:程兴刚
--  发布时间:2013/7/10 0:46:00
--  
和您的代码有天壤之别,我的可以输入任意条件!
--  作者:seal51
--  发布时间:2013/7/10 9:01:00
--  
谢谢老师的回复!我可能没有说清问题,从代码的执行的情况看, 只能先输入产品图号查询,然后才能查询中文名称等信息,我的意思是只查询各自的信息, 产品图号,只查询产品图号, 中文名称,只查询中文名称, 各个查询之间无任何联系,都是各自独立的!
--  作者:seal51
--  发布时间:2013/7/10 21:55:00
--  

还没搞好呢,请老师指点!


--  作者:狐狸爸爸
--  发布时间:2013/7/10 22:05:00
--  

你不能这样设计的,你看看这个:

 

http://www.foxtable.com/help/topics/1058.htm

 

搞不定就做个例子发上来吧。


--  作者:seal51
--  发布时间:2013/7/11 0:07:00
--  

谢谢回复!我学了这个设计,不过,这个设计是相对产品比较规整,重复的产品名称比较多,这样设计比较好, 我们的产品很少有重复的,不好分类,要在众多的产品中找到一个产品不容易,所以想到通过输入数据查询比较好,我想就是模糊查询了,有无这样的例子