Foxtable(狐表)用户栏目专家坐堂 → 模糊查询


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

主题:模糊查询

帅哥哟,离线,有人找我吗?
狐狸爸爸
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2014/2/27 11:01:00 [显示全部帖子]

实际上,只有字符列才能Like,加上判断就行:

 

With e.Form
    If e.sender.text <> "输入计划号/订单号查询" Then
        Dim txt As String = e.Form.Controls("a").Text
        If txt = "" Then
            Tables("合同信息").Filter = ""
        Else
            Dim Filter As String
            For Each c As Col In Tables("合同信息").cols
                if c.IsString Then
                     Filter = Filter & c.name & " like '*" & txt  & "*' or "
                End if

            Next
            Filter=Filter.trim().substring(0,Filter.length-3)
            Tables("合同信息").Filter=Filter
        End If
    End If
End With


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2014/2/27 11:04:00 [显示全部帖子]

还有,既然你输入的查询内容只是计划号或订单号,没有必要遍历所有列,直接指定这两列即可:

 

With e.Form
    If e.sender.text <> "输入计划号/订单号查询" Then
        Dim txt As String = e.Form.Controls("a").Text
        If txt = "" Then
            Tables("合同信息").Filter = ""
        Else
            Tables("合同信息").Filter= “计划号  like '*" & txt  & "*' or 订单号 Like '*" & txt & "*'"
        End If
    End If
End With

[此贴子已经被作者于2014-2-27 11:04:27编辑过]

 回到顶部