以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  筛选的代码求帮助  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=127675)

--  作者:304376480
--  发布时间:2018/11/19 20:43:00
--  筛选的代码求帮助
老师您好,下面是一个搜索框的代码,但还有一个仓库属性不知道该怎么加进去?让筛选在同一个仓库中筛选

Dim cangku As string = e.Form.Controls("仓库").Text

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("产品")
If txt = "" Then
    tbl.Filter = ""
Else
    txt = "\'%" & txt & "%\'"
    tbl.Filter = "商品ID Like " & txt & " Or 商品名称 Like " & txt & "  Or 拼音码 Like " & txt 
End If
[此贴子已经被作者于2018/11/19 20:43:42编辑过]

--  作者:y2287958
--  发布时间:2018/11/19 21:22:00
--  
不明白意思
--  作者:有点蓝
--  发布时间:2018/11/19 21:51:00
--  
参考:http://www.foxtable.com/webhelp/scr/1058.htm

Dim Filter As String
With e.Form.Controls("仓库")
    If .Value IsNot Nothing Then
        Filter = "仓库属性 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "\'%" & .txt & "%\'"
        Filter = Filter & "(商品ID Like " & txt & " Or 商品名称 Like " & txt & "  Or 拼音码 Like " & txt  & ")"
    End If
End With
Tables("产品").Filter  = Filter 

--  作者:304376480
--  发布时间:2018/11/19 21:58:00
--  
可以了,谢谢老师
最后一行代码改成这样就可以了  
tbl.Filter = "仓库 = \'" & cangku & "\'and (商品ID Like " & txt & " Or 商品名称 Like " & txt & "  Or 拼音码 Like " & txt & ")"

前面用and 后面用 or 这个要加到帮助文档上做个示例才好啊,因为新手,标点符号老是对不上,哈哈!


[此贴子已经被作者于2018/11/19 22:34:33编辑过]

--  作者:有点蓝
--  发布时间:2018/11/19 22:24:00
--  
Dim Filter As String
With e.Form.Controls("仓库")
    If .Value IsNot Nothing Then
        Filter = "仓库 = \'" & .Value & "\'"
    End If
End With

With e.Form.Controls("TextBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Dim txt As String = "\'%" & .txt & "%\'"
        Filter = Filter & "(商品ID Like " & txt & " Or 商品名称 Like " & txt & "  Or 拼音码 Like " & txt  & ")"
    End If
End With
Tables("产品").Filter  = Filter


--  作者:304376480
--  发布时间:2018/11/19 22:41:00
--  
谢谢!老师,我把四楼重新编辑完才看到老师在五楼图片点击可在新窗口打开查看

[此贴子已经被作者于2018/11/19 22:43:36编辑过]