Foxtable(狐表)用户栏目专家坐堂 → [求助]查询语句


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

主题:[求助]查询语句

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


加好友 发短信
等级:婴狐 帖子:33 积分:379 威望:0 精华:0 注册:2018/8/28 16:39:00
[求助]查询语句  发帖心情 Post By:2018/12/7 14:48:00 [显示全部帖子]

问题如下:
表里有A B C D E 五列,五列中有相同值出现的情况。
我搞了个按钮,功能为查找任意列有1这个值出现的结果。现在想要增加功能,变为查询任意列有1,并且有2出现的结果。
放两个combox 放num1 和num2的值,然后查找。
请问我的代码要怎么改?

Dim Filter As String
With e.Form.Controls("num1")
    If .Value IsNot Nothing Then
        Filter = "A = '" & .Value & "'"
    End If
End With
With e.Form.Controls("num1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " Or "
        End If
        Filter = Filter & "B = '" & .Value & "'"
    End If
End With
With e.Form.Controls("num1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " Or "
        End If
        Filter = Filter & "C = '" & .Value & "'"
    End If
End With
With e.Form.Controls("num1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " Or "
        End If
        Filter = Filter & "D = '" & .Value & "'"
    End If
End With
With e.Form.Controls("num1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " Or "
        End If
        Filter = Filter & "E = '" & .Value & "'"
    End If
End With
 If Filter > "" Then
     Tables("information").Filter = Filter
 End If
[此贴子已经被作者于2018/12/7 14:50:41编辑过]

 回到顶部