以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]逐级筛选  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=109667)

--  作者:cd_tdh
--  发布时间:2017/11/16 15:31:00
--  [求助]逐级筛选


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

老师,之前看到过这样的论坛,没找到在哪儿了,如图,我在控件“姓名“的TextChanged代码:

Dim Filter As String
With e.Form.Controls("姓名")
    If .Value IsNot Nothing Then
        Filter = "姓名 = \'" & .Value & "\'"
    End If
End With
If Filter > "" Then
    Tables("员工档案").Filter = Filter
End If

当我筛选后,在“在职状态“的TextChanged代码:

Dim Filter As String
With e.Form.Controls("在职状态")
    If .Value IsNot Nothing Then
        Filter = "在职状态 = \'" & .Value & "\'"
    End If
End With
If Filter > "" Then
    Tables("员工档案").Filter = Filter
End If

没有实现,在姓名筛选后的基础上进行筛选,而是又单独筛选了一次全部符合在职状态的数据,需要逐级筛选这个怎么改呢?


--  作者:有点甜
--  发布时间:2017/11/16 15:33:00
--  

参考

 

http://www.foxtable.com/webhelp/scr/1058.htm

 


--  作者:cd_tdh
--  发布时间:2017/11/16 16:21:00
--  

老师,还是有点问题,比如我先选择所属机构,在选择项目类别,出来的还是结果还是项目类别的结果,不是选择的所属机构中项目类别的结果呢?还有就是,当我先选择后面的选项,在选择线面的选项,不执行。

Dim Filter As String
With e.Form.Controls("项目编码")
    If .Value IsNot Nothing Then
        Filter = "项目编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("所属机构")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = "所属机构 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("项目类别")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        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 & "项目名称 like \'%" & .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 Filter > "" Then
    Tables("中标统计").Filter = Filter
End If


[此贴子已经被作者于2017/11/17 12:02:36编辑过]

--  作者:cd_tdh
--  发布时间:2017/11/17 12:03:00
--  

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目4.foxdb

--  作者:有点甜
--  发布时间:2017/11/17 12:21:00
--  
Dim Filter As String
With e.Form.Controls("项目编码")
    If .Value <> Nothing Then
        Filter = "项目编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("所属机构")
    If .Value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "所属机构 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("项目类别")
    If .Value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "项目类别 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("项目名称")
    If .Value <> Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "项目名称 like \'%" & .Value & "%\'"
    End If
End With
With e.Form.Controls("起始日期")
    If .Value <> Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "中标日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("截止日期")
    If .Value <> Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "中标日期 <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
    Tables("表A").Filter = Filter
End If

--  作者:cd_tdh
--  发布时间:2017/11/17 12:32:00
--  

IsNot 和 <>有什么区别?


--  作者:有点甜
--  发布时间:2017/11/17 14:12:00
--  
以下是引用cd_tdh在2017/11/17 12:32:00的发言:

IsNot 和 <>有什么区别?

 

关键是这个代码

 

Filter &= "所属机构 = \'" & .Value & "\'"

 

Filter = Filter & "所属机构 = \'" & .Value & "\'"


--  作者:cd_tdh
--  发布时间:2017/11/17 16:31:00
--  
以下是引用有点甜在2017/11/17 14:12:00的发言:

 

关键是这个代码

 

Filter &= "所属机构 = \'" & .Value & "\'"

 

Filter = Filter & "所属机构 = \'" & .Value & "\'"

这个注意到了,这两种写法是一个意思吗?


--  作者:有点甜
--  发布时间:2017/11/17 16:42:00
--  
以下是引用cd_tdh在2017/11/17 16:31:00的发言:

这个注意到了,这两种写法是一个意思吗?

 

是的。

 

isnot 和 <> 基本没有区别,判断基本类型(字符串、数字、日期等)一般都用 <>,判断对象(datarow、dattatable等)一般用 isNot


--  作者:cd_tdh
--  发布时间:2018/5/16 14:31:00
--  

有点甜老师,有个签订状态,怎么一起加入筛选:

代码如下:

With e.Form.Controls("签订状态")
    If .Value="已签订" Or .Value="未签订"
        Filter = "签订状态 = \'" & .Value & "\'"
    Else
        Filter = "签订状态 is null"
    End If
End With