以文本方式查看主题

-  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=118392)

--  作者:7877485
--  发布时间:2018/5/1 22:25:00
--  窗口筛选问题
If e.Form.Controls("yibi").Checked = True \'如果闭环状态选择了"已闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "配件名称 <> 待料"
End If
If e.Form.Controls("weibi").Checked = True \'如果闭环状态选择了"未闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "已闭 = False Or 已闭 Is Null"
End If

图片点击可在新窗口打开查看此主题相关图片如下:捕获.png
图片点击可在新窗口打开查看
我照着窗口筛选示例做的,现在有一个闭环状态:已闭  和  未闭  
已闭的条件是配件名称不等于“待料”
未闭的条件是配件名称等于“待料”
该怎么写?


[此贴子已经被作者于2018/5/1 23:15:10编辑过]

--  作者:7877485
--  发布时间:2018/5/1 23:17: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 = 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("StartDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
If e.Form.Controls("yibi").Checked = True \'如果闭环状态选择了"已闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "配件名称 <> 待料"
End If
If e.Form.Controls("weibi").Checked = True \'如果闭环状态选择了"未闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "已闭 = False Or 已闭 Is Null"
End If
If Filter > "" Then
    Tables("查询窗口_碎修记录").Filter = Filter
完整的代码

--  作者:有点甜
--  发布时间:2018/5/2 9:07:00
--  
If e.Form.Controls("yibi").Checked = True \'如果闭环状态选择了"已闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "配件名称 <> \'待料\' or 配件名称 is null"
End If
If e.Form.Controls("weibi").Checked = True \'如果闭环状态选择了"未闭"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "配件名称 = \'待料\'"
End If