Foxtable(狐表)用户栏目专家坐堂 → TextChanged


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

主题:TextChanged

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


加好友 发短信
等级:四尾狐 帖子:822 积分:6432 威望:0 精华:0 注册:2013/2/18 17:46:00
TextChanged  发帖心情 Post By:2024/9/26 9:32:00 [只看该作者]

.NET Framework 版本:4.0.30319.1
Foxtable 版本:2022.8.18.1
错误所在事件:
详细错误信息:
Cannot perform 'Like' operation on System.String and System.Int32.

 

Dim Filter As String
Dim txt As String = e.Form.Controls("TextBox1").Text
If txt = "" Then
   Filter = ""
Else
   txt = "'%" & txt & "%'"
Filter = "(车台产品编号 like " & txt & "Or 加工单位 Like " & txt & ")"
End If
''msgbox(Filter)


Dim txt2 As String = e.Form.Controls("TextBox2").Text
If txt2 > "" Then
   If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "(车台产品编号 like " & txt2 & "Or 加工单位 Like " & txt2 & ")"
End If

'msgbox(Filter)

 


If Filter > "" Then
    Tables("模具清单_Table03").Filter = Filter
End If


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


加好友 发短信
等级:狐精 帖子:3215 积分:21361 威望:0 精华:0 注册:2016/3/28 16:57:00
  发帖心情 Post By:2024/9/26 9:59:00 [只看该作者]

这个意思?
Dim Filter As String
With e.Form.Controls("TextBox1")
    If .Value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "车台产品编号 like '%" & .Value & "%'"
    End If
End With
With e.Form.Controls("TextBox2")
    If .Value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "加工单位 like '%" & .Value & "%'"
    End If
End With
If Filter > "" Then
    Tables("表A").Filter = Filter
End If
[此贴子已经被作者于2024/9/26 9:59:20编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110836 积分:564124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/9/26 10:21:00 [只看该作者]

字符列才能使用like,整数列要做转换。

Filter = Filter & "convert(车台产品编号,'System.String') like '%" & .Value & "%'"

另外,多个控件条件查询建议使用这种用法:http://www.foxtable.com/webhelp/topics/1058.htm

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


加好友 发短信
等级:四尾狐 帖子:822 积分:6432 威望:0 精华:0 注册:2013/2/18 17:46:00
  发帖心情 Post By:2024/9/26 10:21:00 [只看该作者]

原因找到了。

Dim Filter As String
Dim txt As String = e.Form.Controls("TextBox1").Text
txt = "'%" & txt & "%'"
If txt > "" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = "(车台产品编号 like " & txt & "Or 加工单位 Like " & txt & ")"
        msgbox(Filter)
End If

Dim txt2 As String = e.Form.Controls("TextBox2").Text
txt2 = "'%" & txt2 & "%'"   少了这行代码
If txt2 > "" Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "(车台产品编号 like " & txt2 & "Or 加工单位 Like " & txt2 & ")"
    msgbox(Filter)


End If

If Filter > "" Then
    Tables("模具清单_Table03").Filter = Filter
End If


 回到顶部