以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]一个按键如何同时执行筛选和交叉查询》?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=20613)

--  作者:wangwenlon
--  发布时间:2012/6/13 17:47: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
("2012年数据").Filter = Filter
End
If

 

Dim g As New CrossTableBuilder("统计表1", DataTables("2012年数据"))
g.Caption = "下属企业经营情况"
g.HGroups.AddDef("下属企业")
g.VGroups.AddDef("经营范围")
g.Totals.AddDef("项目编号", AggregateEnum.Count, "项目编号")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Build()
MainTable = Tables("统计表1")


--  作者:sloyy
--  发布时间:2012/6/13 17:59: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

 

Dim g As New CrossTableBuilder("统计表1", DataTables("2012年数据"))

g.Filter=Filter
g.Caption = "下属企业经营情况"
g.HGroups.AddDef("下属企业")
g.VGroups.AddDef("经营范围")
g.Totals.AddDef("项目编号", AggregateEnum.Count, "项目编号")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Build()
MainTable = Tables("统计表1")


--  作者:wangwenlon
--  发布时间:2012/6/13 18:06:00
--  
谢谢