Foxtable(狐表)用户栏目专家坐堂 → 复选框筛选


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

主题:复选框筛选

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/12/5 9:05:00 [显示全部帖子]

在代码的最后加三行:

 

MessageBox.show("Filter1 =" & Filter1)

MessageBox.show("Filter =" & Filter)

MessageBox.show("生效的 =" & Tables("中兴明细").Filter )

 

你就知道原因了。

 

你下面的代码意义何在:

 

If Filter > "" Then
     If Filter1 > "" Then
          Tables("中兴明细").Filter = Filter1
     End If
     Tables("中兴明细").Filter = Filter
End If

 

只要Filter不为空才执行,而且Filter不为空的时候,最终将筛选条件设置成Filter了,和Filter1没有任何关系了。

[此贴子已经被作者于2011-12-5 9:04:42编辑过]

 回到顶部
帅哥,在线噢!
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/12/5 10:21:00 [显示全部帖子]

我不明白你为什么要分开Filter和Filter,一个不就行啦吗:

 

 

Dim Filter As String
Dim chk1 As WinForm.CheckBox = Forms("中兴明细").Controls("入仓")
Dim chk2 As WinForm.CheckBox = Forms("中兴明细").Controls("出仓")
With e.Form.Controls("型号")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "型号 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("规格")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "规格 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("颜色")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "颜色 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("开始日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("截止日期")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("月份")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "月份 = '" & .Value & "'"
    End If
End With
If chk1.Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "[入仓数量] Is Not Null"
End If
If chk2.Checked = True Then
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter &  "[出仓数量] Is Not Null"
End If
If Filter > "" Then
    Tables("中兴明细").Filter = Filter
End If

 


 回到顶部