以文本方式查看主题

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

--  作者:tis0046
--  发布时间:2017/10/1 12:40:00
--  求大神看一下,筛选的命令对不对
Dim Filter As String
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


想设计一个筛选, 从开始日期到结束日期筛选,输入以上Click事件代码后,设计的筛选没有任何反映

--  作者:lindong
--  发布时间:2017/10/1 15:35:00
--  
Dim Filter As String
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 Filter > "" then

tables("表名").Filter =Filter

end if

 


--  作者:tis0046
--  发布时间:2017/10/1 16:16:00
--  
太棒了,完美解决
--  作者:tis0046
--  发布时间:2017/10/1 16:29:00
--  
还想再问一下,如果我在窗口里设计一个table(表),想让筛查的数据都反映这个表上,命令应该怎么写?table(表)已经绑定表A及设定为副本
Dim Filter As String
Dim tbl As Table = e.Form.Controls("Table1").Table
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 Filter > "" Then
Tables("表A").Filter =Filter
End If

这样写可以吗?

--  作者:lindong
--  发布时间:2017/10/1 20:05:00
--  
Tables("表A").Filter =Filter 改为 Tables("窗口名_table1").Filter =Filter