以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何读取复选组合框来内容筛选数据  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86023)

--  作者:simve_seven
--  发布时间:2016/6/8 10:39:00
--  如何读取复选组合框来内容筛选数据
请问一下,如何通过复选组合框来筛选数据
图片点击可在新窗口打开查看此主题相关图片如下:图片1.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/6/8 11:55:00
--  

参考

 

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

 

大致代码 "机器名称 in (\'" & 控件.Text.Replace(",", "\',\'") & "\')"


--  作者:simve_seven
--  发布时间:2016/6/14 15:32:00
--  

您好,

    按您说的还是不行,这个我都搞晕了,我做力学分析的,着急做个数据筛选工具,对这个不太灵光,求指教,谢谢了

Dim Filter As String
With e.Form.Controls("机型名称1")
    If .Value IsNot Nothing Then
        If "机器名称 in (\'" & .Text.Replace(",", "\',\'") & "\')" Then
            Tables("机型数据汇总").Filter = "机型名称 = \'" & .Value & "\'"
        End If
    End If
End With
With e.Form.Controls("器件代码1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Tables("机型数据汇总").Filter = Filter & "器件代码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("器件名称1")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Tables("机型数据汇总").Filter = Filter & "器件名称 = \'" & .Value & "\'"
    End If
End With

 

 


图片点击可在新窗口打开查看此主题相关图片如下:aaaaaa.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/6/14 15:41:00
--  
Dim Filter As String = "1=1"
With e.Form.Controls("机型名称1")
    If .Value IsNot Nothing Then
        Filter &= " and 机器名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件代码1")
    If .Value IsNot Nothing Then
        Filter &= " and 器件代码 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件名称1")
    If .Value IsNot Nothing Then
        Filter &= " and 器件名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With

--  作者:simve_seven
--  发布时间:2016/6/14 16:13:00
--  

非常感谢您的帮助,但还是有点小问题,详见附件,我把代码改了一下:

 

 Dim Filter As String = "1=1"
With e.Form.Controls("机型名称1")
    If .Value IsNot Nothing Then
        Tables("机型数据汇总").Filter &= " and 机型名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件代码1")
    If .Value IsNot Nothing Then
        Tables("机型数据汇总").Filter &= " and 器件代码 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件名称1")
    If .Value IsNot Nothing Then
        Tables("机型数据汇总").Filter &= " and 器件名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With

 


图片点击可在新窗口打开查看此主题相关图片如下:aaaaaa.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2016/6/14 16:36:00
--  

Dim Filter As String = "1=1"
With e.Form.Controls("机型名称1")
    If .Value IsNot Nothing Then
        Filter &= " and 机器名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件代码1")
    If .Value IsNot Nothing Then
        Filter &= " and 器件代码 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件名称1")
    If .Value IsNot Nothing Then
        Filter &= " and 器件名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With

 

Tables("机型数据汇总").Filter = Filter

 

 


--  作者:simve_seven
--  发布时间:2016/6/14 16:50:00
--  

谢谢,我用下面的方式也搞定了,太谢谢你了

Dim Filter As String = "1=1"
With e.Form.Controls("机型名称1")
    If .Value IsNot Nothing Then
        Tables("机型数据汇总").Filter= "  机型名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件代码1")
   
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Tables("机型数据汇总").Filter & = " and 器件代码 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With
With e.Form.Controls("器件名称1")
   
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Tables("机型数据汇总").Filter & = " and 器件名称 in (\'" & .Text.Replace(",", "\',\'") & "\')"
    End If
End With


--  作者:大红袍
--  发布时间:2016/6/14 16:54:00
--  

你7楼写法有问题。不能那样写。

 

直接拷贝6楼。


--  作者:simve_seven
--  发布时间:2016/6/14 16:58:00
--  
还是你那个好用些,也全是我想要的,再次谢谢了
--  作者:simve_seven
--  发布时间:2016/6/14 17:02:00
--  

是的,确实有问题,谢谢了,问题解决了,后续沉下心好好学习下这个,太牛了