Foxtable(狐表)用户栏目专家坐堂 → 哎,还是关于多条件筛选的问题,自己写了代码,出错了。


  共有3149人关注过本帖平板打印复制链接

主题:哎,还是关于多条件筛选的问题,自己写了代码,出错了。

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


加好友 发短信
等级:童狐 帖子:223 积分:1562 威望:0 精华:0 注册:2014/9/17 19:08:00
哎,还是关于多条件筛选的问题,自己写了代码,出错了。  发帖心情 Post By:2014/11/27 23:01:00 [只看该作者]

表A是专合社基础资料表,假设里面有100个专合社,每个客户有唯一的编号(工商登记号)。表A,表B以编号关联。表B是政府支持专合社统计表,假设里面有A,B,C三个专合社分别于2012年1月1日,2013年1月1日,2014年1月1日有一笔购买记录。

现在做了一个窗口,做了起止时间timepicker,做了筛选按钮,想实现的功能为:假设设置起止时间为2012年1月1日-2013年12月31日(时间是要筛选表B的)。那么datatable表A只加载除了AB以外的所有客户,然后如果条件设置里combobox1设置为全市,就加载所有县区的符合条件的的,设置为某县就只加载某县符合条件的。combobox2设置为专合社类别,设置全部类别就加载所有符合条件的。设置某类型(如畜牧养殖类)就只加载畜牧养殖类型中符合条件的。自己写的开始筛选代码如下。(甜老师早上已经指点)

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
With e.Form.Controls("combobox1")
    
If .Value IsNot Nothing Then
        Filter = 
"区域 = '" & .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 & 
"专合社类别 = '" & .Value & "'"
    
End If
End
 With

DataTables("表A").LoadFilter = "编号 not in (select 编号 from {表B} where " & filter & ")"
DataTables("表A").Load

已经乱了,求大神帮忙。。



此主题相关图片如下:unnamed qq screenshot20141127224455.png
按此在新窗口浏览图片

此主题相关图片如下:unnamed qq screenshot20141127224418.png
按此在新窗口浏览图片

此主题相关图片如下:unnamed qq screenshot20141127224353.png
按此在新窗口浏览图片

 回到顶部
总数 13 1 2 下一页