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


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

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

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


加好友 发短信
等级:童狐 帖子:223 积分:1562 威望:0 精华:0 注册:2014/9/17 19:08:00
  发帖心情 Post By:2014/11/30 22:59:00 [只看该作者]

可以筛选了!现在不过只能筛选出某一个类别和某一个地区的。。。原因是combobox里面的专合社类别我设置了全部类别,还有地区我设置了全市,列里面没有响应的值,例如只有畜牧养殖类,蔬果种植类。。,想实现的功能就是选择全市全部类别就出现所有符合的行,现在如果设置全市和全部类别,一加载就没有一条行出现。请问有办法解决没。

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


加好友 发短信
等级:童狐 帖子:223 积分:1562 威望:0 精华:0 注册:2014/9/17 19:08:00
  发帖心情 Post By:2014/11/30 23:15: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 & "'"

    If.Value="全部类别" Then

    Filter2=" "

    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        filter2 = filter2 & " and 第1列 = '" & .Value & "'"

 If.Value="全市" Then

    Filter2=" "

    End If
End With


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

DataTables("表A").Load


甜老师晚安,上午帮小弟再看看我在代码里面加的代码对不对。

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


加好友 发短信
等级:童狐 帖子:223 积分:1562 威望:0 精华:0 注册:2014/9/17 19:08:00
  发帖心情 Post By:2014/11/30 23:33: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 & "'"

    If.Value="全部类别" Then

    Filter2=" "

    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        filter2 = filter2 & " and 第1列 = '" & .Value & "'"

 If.Value="全市" Then

    Filter2=" "

    End If
End With


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

DataTables("表A").Load


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


加好友 发短信
等级:童狐 帖子:223 积分:1562 威望:0 精华:0 注册:2014/9/17 19:08:00
  发帖心情 Post By:2014/11/30 23:37: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 & "'"

    If.Value="全部类别" Then

    Filter2=Filter2 & " And 第2列 = " "

    End If
End With
With e.Form.Controls("combobox2")
    If .Value IsNot Nothing Then
        filter2 = filter2 & " and 第1列 = '" & .Value & "'"

 If.Value="全市" Then

    Filter2=filter2& " and 第1列 = " "

    End If
End With


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

DataTables("表A").Load



 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  35楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部
总数 35 上一页 1 2 3 4