以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]请问如何按起止日期进行交叉统计?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=14703)

--  作者:yrdfl
--  发布时间:2011/11/29 12:46:00
--  [求助]请问如何按起止日期进行交叉统计?
请问如何按起止日期进行交叉统计?,通过设计窗口实现此功能,求教代码。谢谢!
--  作者:狐狸爸爸
--  发布时间:2011/11/29 13:06:00
--  
关于查询窗口的设计,看看:
http://www.foxtable.com/help/topics/1058.htm
 
单单日期的话,插入两个日期输入框:

Dim Filter As String
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        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 b As New CrossTableBuilder("统计表1",DataTables("订单"))
b.HGroups.AddDef("客户")
b.VGroups.AddDef("产品")
b.Totals.AddDef("数量")
b.Filter = Filter
b.Build
Maintable = Tables("统计表1")

--  作者:yrdfl
--  发布时间:2011/11/30 12:03:00
--  
狐爸,您好,你奉献的代码还是实现不了这个功能,烦请您帮我看看附件!
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:公车管理.table


--  作者:yrdfl
--  发布时间:2011/11/30 13:38:00
--  

--  作者:yangming
--  发布时间:2011/11/30 13:54:00
--  

按车号:

Dim Filter As String
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        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 b As New CrossTableBuilder("统计表1",DataTables("班线营收"))
b.HGroups.AddDef("车号")
b.VGroups.AddDef("日期")
b.Totals.AddDef("运行里程")
b.Totals.AddDef("运量人数")
b.Totals.AddDef("运量金额")
b.Totals.AddDef("路配人数")
b.Totals.AddDef("路配金额")
b.Totals.AddDef("小件营收")
b.Totals.AddDef("人数合计")
b.Totals.AddDef("营收合计")
b.OrderByTotal = True
b.VerticalTotal= True
b.Filter = Filter
b.Build
MainTable = Tables("统计表1")

 

按驾驶员

Dim Filter As String
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        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 b As New CrossTableBuilder("统计表1",DataTables("班线营收"))
b.HGroups.AddDef("驾驶员")
b.VGroups.AddDef("日期")
b.Totals.AddDef("运行里程")
b.Totals.AddDef("运量人数")
b.Totals.AddDef("运量金额")
b.Totals.AddDef("路配人数")
b.Totals.AddDef("路配金额")
b.Totals.AddDef("小件营收")
b.Totals.AddDef("人数合计")
b.Totals.AddDef("营收合计")
b.OrderByTotal = True
b.VerticalTotal= True
b.Filter = Filter
b.Build
MainTable = Tables("统计表1")

 

 

按乘务员

Dim Filter As String
With e.Form.Controls("StartDate")
    If .Value IsNot Nothing Then
        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 b As New CrossTableBuilder("统计表1",DataTables("班线营收"))
b.HGroups.AddDef("乘务员")
b.VGroups.AddDef("日期")
b.Totals.AddDef("运行里程")
b.Totals.AddDef("运量人数")
b.Totals.AddDef("运量金额")
b.Totals.AddDef("路配人数")
b.Totals.AddDef("路配金额")
b.Totals.AddDef("小件营收")
b.Totals.AddDef("人数合计")
b.Totals.AddDef("营收合计")
b.OrderByTotal = True
b.VerticalTotal= True
b.Filter = Filter
b.Build
MainTable = Tables("统计表1")

[此贴子已经被作者于2011-11-30 13:56:49编辑过]