Office中国论坛/Access中国论坛

标题: 这个报表如何做? [打印本页]

作者: qqqq    时间: 2004-2-27 21:04
标题: 这个报表如何做?
报表联接字段有日期/项目/金额。。
一个月的数据是从如:2004-01-26到2004-02-25为止
现在我是想做一小结报表(按项目分类汇总)日期分五个小段。分别是:
2004-01-26------2004-02-05
2004-02-06------2004-02-10
2004-02-11------2004-02-15
2004-02-16------2004-02-20
2004-02-21------2004-02-25
现在的问题是如何按上述日期分段条件做出一个报表,
并做在一个报表里面。

速盼同路人指点。。。。。。

作者: hi-wzj    时间: 2004-2-27 22:10
若是按每4天汇总的化,报表向导里的分组依据就有。
作者: zhuyiwen    时间: 2004-2-27 22:48
用自定义的VBA函数来分组

Public Function SplitDay(ByVal Daily As Date) As String
    If Day(Daily) >= 26 Then
        SplitDay = "第一段"
    ElseIf Day(Daily) >= 21 Then
        SplitDay = "第五段"
    ElseIf Day(Daily) >= 16 Then
        SplitDay = "第四段"
    ElseIf Day(Daily) >= 11 Then
        SplitDay = "第三段"
    ElseIf Day(Daily) >= 6 Then
        SplitDay = "第二段"
    Else
        SplitDay = "第一段"
    End If
    SplitDay = Year(Daily) & "年" & Month(Daily) & "月" & SplitDay
End Function

在SQL语句中
GROUP BY SplitDay([日期字段])
作者: zhuyiwen    时间: 2004-2-27 22:58
修正:

Public Function SplitDay(ByVal Daily As Date) As String
    If Day(Daily) >= 26 Then
        SplitDay = Year(Daily) & "-" & Month(Daily) & "-26--" & Year(Daily + 10) & "-" & Month(Daily + 10) & "-05"
    ElseIf Day(Daily) >= 21 Then
        SplitDay = Year(Daily) & "-" & Month(Daily) & "-21--" & Year(Daily) & "-" & Month(Daily) & "-25"
    ElseIf Day(Daily) >= 16 Then
        SplitDay = Year(Daily) & "-" & Month(Daily) & "-16--" & Year(Daily) & "-" & Month(Daily) & "-20"
    ElseIf Day(Daily) >= 11 Then
        SplitDay = Year(Daily) & "-" & Month(Daily) & "-11--" & Year(Daily) & "-" & Month(Daily) & "-15"
    ElseIf Day(Daily) >= 6 Then
        SplitDay = Year(Daily) & "-" & Month(Daily) & "-06--" & Year(Daily) & "-" & Month(Daily) & "-10"
    Else
        SplitDay = Year(Daily - 10) & "-" & Month(Daily - 10) & "-26--" & Year(Daily) & "-" & Month(Daily) & "-05"
    End If
End Function

作者: qqqq    时间: 2004-2-29 02:36
非常感谢朱兄。。
已测试完成,完全符合的我的想法。。谢谢!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3