Foxtable(狐表)用户栏目专家坐堂 → 双表条件筛选,感谢BIN老师甜老师指点,代码不报错了,但筛选不出来。


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

主题:双表条件筛选,感谢BIN老师甜老师指点,代码不报错了,但筛选不出来。

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/29 21:58:00 [显示全部帖子]

贴出你报错的代码

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 9:22:00 [显示全部帖子]

Dim Filter As String = "1=1"

With e.Form.Controls("DateTimePicker1")

If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        Filter = " and 第2列 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & " and 第1列 = '" & .Value & "'"
    End If
End With


DataTables("表A").LoadFilter = "第4列 not in (select iif(第七列 is null, '', 第七列) from {表B} where " & filter & ")"

DataTables("表A").Load
output.show(DataTables("表A").LoadFilter)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 20:52:00 [显示全部帖子]

 如果是sqlserver数据库,这样改

 

DataTables("表A").LoadFilter = "第4列 not in (select isnull(第七列, '') from {表B} where " & filter & ")"


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 21:38:00 [显示全部帖子]

Dim Filter As String = "1=1"

With e.Form.Controls("DateTimePicker1")

If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 <= #" & .Value & "#"
    End If
End With
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        Filter = " and 第2列 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 第1列 = '" & .Value & "'"
    End If
End With

DataTables("表A").LoadFilter = "第4列 not in (select isnull(第七列, '') from {表B} where " & filter & ")"

DataTables("表A").Load


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 21:59:00 [显示全部帖子]

Dim Filter As String = "1=1"

With e.Form.Controls("DateTimePicker1")

If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 >= '" & .Value & "'"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 第六列 <= '" & .Value & "'"
    End If
End With
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        Filter = " and 第2列 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        Filter = Filter & " and 第1列 = '" & .Value & "'"
    End If
End With

DataTables("表A").LoadFilter = "第4列 not in (select isnull(第七列, '') from {表B} where " & filter & ")"

DataTables("表A").Load

[此贴子已经被作者于2014-11-30 21:59:39编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 22:26:00 [显示全部帖子]

 不可能错。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/11/30 22:45:00 [显示全部帖子]

Dim filter1 As String = "1=1"

With e.Form.Controls("DateTimePicker1")

If .Value IsNot Nothing Then
        filter1 = filter1 & " and 第六列 >= '" & .Value & "'"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        filter1 = filter1 & " and 第六列 <= '" & .Value & "'"
    End If
End With
Dim filter2 As String = "1=1"
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        filter2 = Filter2 & " And 第2列 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        filter2 = filter2 & " and 第1列 = '" & .Value & "'"
    End If
End With


DataTables("表A").LoadFilter = "第4列 not in (select isnull(第七列, '') from {表B} where " & filter1 & ") and " & filter2

DataTables("表A").Load


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/12/1 9:13:00 [显示全部帖子]

Dim filter1 As String = "1=1"

With e.Form.Controls("DateTimePicker1")
   
    If .Value IsNot Nothing Then
        filter1 = filter1 & " and 第六列 >= '" & .Value & "'"
    End If
End With
With e.Form.Controls("DateTimePicker2")
    If .Value IsNot Nothing Then
        filter1 = filter1 & " and 第六列 <= '" & .Value & "'"
    End If
End With
Dim filter2 As String = "1=1"
With e.Form.Controls("combobox1")
    If .Value IsNot Nothing Then
        If.Value <> "全部类别" Then
        filter2 = Filter2 & " And 第2列 = '" & .Value & "'"
    End If
End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        If.Value <> "全市" Then
        filter2 = filter2 & " and 第1列 = '" & .Value & "'"
    End If
End If
End With


DataTables("表A").LoadFilter = "第4列 not in (select isnull(第七列, '') from {表B} where " & filter1 & ") and " & filter2

DataTables("表A").Load


 回到顶部