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


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

主题:Filter

帅哥,在线噢!
1234567
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

Dim Filter As String

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim tbl As Table = Tables("窗口_Table1")
If txt = "" Then
   tbl.Filter = ""
Else
Filter = "第一列='" & txt1 & "'"
   Tables("窗口_Table1").Filter = Filter
End If

 

当我在TextBox1填入数据A时,Filter = "第一列='A'",

当我在TextBox1重新填入数据B时,Filter = "第一列='A'" OR "第一列='B'" ,如何实现?


 


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


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

……
If txt = "" Then
   tbl.Filter = ""
Else
Filter = "第一列='" & txt1 & "'"
if Tables("窗口_Table1").Filter > "" then 
Tables("窗口_Table1").Filter = Tables("窗口_Table1").Filter & " or "
end if
   Tables("窗口_Table1").Filter = Tables("窗口_Table1").Filter & Filter
End If

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


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

.NET Framework 版本:4.0.30319.1
Foxtable 版本:2022.8.18.1
错误所在事件:
详细错误信息:
Syntax error: Missing operand after 'And' operator.

 

Dim Filter As String
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim txt1 As String = e.Form.Controls("TextBox2").Text
Dim tbl As Table = Tables("五级表|工步_Table1")
If txt = "" OrElse txt1 = "" Then
    tbl.Filter = ""
Else
    Filter = txt & "='" & txt1 & "'"
    msgbox(Filter)
    If Tables("五级表|工步_Table1").Filter > "" Then
        Tables("五级表|工步_Table1").Filter = Tables("五级表|工步_Table1").Filter & "and"
        msgbox(Filter)
    End If
    Tables("五级表|工步_Table1").Filter = Tables("五级表|工步_Table1").Filter & Filter
    msgbox(Filter)
End If


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


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

加上必要的空格

Tables("五级表|工步_Table1").Filter = Tables("五级表|工步_Table1").Filter & " and "

 回到顶部
帅哥,在线噢!
1234567
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

.NET Framework 版本:4.0.30319.1
Foxtable 版本:2022.8.18.1
错误所在事件:
详细错误信息:
Syntax error: Missing operand after 'And' operator.

 

Dim Filter As String
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim txt1 As String = e.Form.Controls("TextBox2").Text
Dim tbl As Table = Tables("五级表|工步_Table1")
If txt = "" OrElse txt1 = "" Then
    tbl.Filter = ""
Else
    Filter = txt & "='" & txt1 & "'"
    msgbox(Filter)
    If Tables("五级表|工步_Table1").Filter > "" Then
        Tables("五级表|工步_Table1").Filter = Tables("五级表|工步_Table1").Filter & " and "
        msgbox(Filter)
    End If
    Tables("五级表|工步_Table1").Filter = Tables("五级表|工步_Table1").Filter & Filter
    msgbox(Filter)
End If


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


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

Else
    Filter = txt & "='" & txt1 & "'"
    msgbox(Filter)
    If Tables("五级表|工步_Table1").Filter > "" Then
        Filter = Filter & " and " & Tables("五级表|工步_Table1").Filter 
        msgbox(Filter)
    End If
    Tables("五级表|工步_Table1").Filter = Filter
End If

 回到顶部
帅哥,在线噢!
1234567
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

Dim Filter As String
Dim idx As String = "-1,"
Dim pdr As DataRow = Nothing
Dim cs As String = "工序,设备名称,机床代号,机床编号,计划作业人员,按时间加工单价"
Dim flag As Boolean
For Each dr As DataRow In DataTables("工艺内容").Select("工序 is not null ", cs)
    flag = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        idx &= pdr("_Identify") & ","
    End If
    pdr = dr
Next

If pdr IsNot Nothing Then
    idx &= pdr("_Identify") & ","
End If


filter = "_Identify in (" & idx.trim(",") & ") and 工序 is not null "
msgbox(Filter)

Dim t1 As String = e.Form.Controls("DropBox1").Text
Dim t01 As String = e.Form.Controls("TextBox3").Text

If t1 <> Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "工序= '" & t1 & "'"
    msgbox(Filter)
End If
If t01 <> Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "机床编号= '" & t01 & "'"
    msgbox(Filter)
End If

 

 

Dim txt As String = e.Form.Controls("TextBox1").Text        我把其他代码整合后,筛选条件只有TextBox2最后输入数据有效,如何才能达到6楼的效果?
Dim txt1 As String = e.Form.Controls("TextBox2").Text
Dim tbl As Table = Tables("四级表|工序_Table1")
If txt = "" OrElse txt1 = "" Then
    Filter = Filter
    msgbox(Filter)
Else
    Filter = Filter & " and " & txt & "='" & txt1 & "'"
   msgbox(Filter)
    If Tables("四级表|工序_Table1").Filter > "" Then
        Filter = Filter & " and " & txt & "='" & txt1 & "'"
      msgbox(Filter)
    End If
    Tables("四级表|工序_Table1").Filter = Filter
End If

 

 

 


If Filter > "" Then
    Tables("四级表|工序_Table1").Filter = Filter
End If

[此贴子已经被作者于2024/10/25 16:08:14编辑过]

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


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

    If Tables("四级表|工序_Table1").Filter > "" Then
        Filter = Filter & " and " & Tables("四级表|工序_Table1").Filter
      msgbox(Filter)
    End If

 回到顶部
帅哥,在线噢!
1234567
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

Dim Filter As String
Dim idx As String = "-1,"
Dim pdr As DataRow = Nothing
Dim cs As String = "工序,设备名称,机床代号,机床编号,计划作业人员,按时间加工单价"
Dim flag As Boolean
For Each dr As DataRow In DataTables("工艺内容").Select("工序 is not null ", cs)
    flag = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        idx &= pdr("_Identify") & ","
    End If
    pdr = dr
Next

If pdr IsNot Nothing Then
    idx &= pdr("_Identify") & ","
End If


filter = "_Identify in (" & idx.trim(",") & ") and 工序 is not null "
msgbox(Filter)

Dim t1 As String = e.Form.Controls("DropBox1").Text
Dim t01 As String = e.Form.Controls("TextBox3").Text

If t1 <> Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "工序= '" & t1 & "'"
    msgbox(Filter)
End If
If t01 <> Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "机床编号= '" & t01 & "'"
    msgbox(Filter)
End If

Dim txt As String = e.Form.Controls("TextBox1").Text
Dim txt1 As String = e.Form.Controls("TextBox2").Text
Dim tbl As Table = Tables("四级表|工序_Table1")
If txt = "" OrElse txt1 = "" Then
    Filter = Filter
    msgbox(Filter)
Else
    Filter = Filter & " and " & txt & "='" & txt1 & "'"
   msgbox(Filter)
     If Tables("四级表|工序_Table1").Filter > "" Then
        Filter = Filter & " and " & Tables("四级表|工序_Table1").Filter   第二次输入时,把上此的数据改写掉了,是否Filter 数据改写了?
      msgbox(Filter)
    End If
    Tables("四级表|工序_Table1").Filter = Filter
End If

If Filter > "" Then
    Tables("四级表|工序_Table1").Filter = Filter
End If


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


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


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

 回到顶部