按日月季年分类统计报表
时 间:2013-08-10 16:38:17
作 者:沈军 ID:2469 城市:东莞
摘 要:根据网友提出相关问题“如何处理日期值中日月季年分类统计的SQL语句”,现做一示例发出来,供大家一起学习。
正 文:
DoCmd.Close acForm, "EBOOKS日期选择1"
DoCmd.OpenForm "EBOOKS日期选择1", , , , , acDialog
If Not IsLoaded("EBOOKS日期选择1") Then
Cancel = -1
Else
Dim sjCXtj, sjBBTJ As String
sjCXtj = "": sjBBTJ = ""
If Not IsNull(Form_EBOOKS日期选择1.开始日期) Then sjCXtj = sjCXtj & "日期>=[forms]![EBOOKS日期选择1]![开始日期] AND "
If Not IsNull(Form_EBOOKS日期选择1.结束日期) Then sjCXtj = sjCXtj & "日期<=[forms]![EBOOKS日期选择1]![结束日期] AND "
If sjCXtj <> "" Then sjCXtj = " Where " & Left(sjCXtj, Len(sjCXtj) - 5)
Me.SJ条件说明.Caption = sjBBTJ
Dim sjTJRQXX As String
sjTJRQXX = ""
Select Case Form_EBOOKS日期选择1.统计方式
Case 1
sjTJRQXX = "Format([日期],'yyyy/mm/dd')"
Me.日期_Label.Caption = "日期"
Me.Label62.Caption = "《帐务统计报表_按日》"
Case 2
sjTJRQXX = "Format([日期],'yyyy年mm月份')"
Me.日期_Label.Caption = "月份"
Me.Label62.Caption = "《帐务统计报表_按月》"
Case 3
sjTJRQXX = "Format([日期],'yyyy年q季')"
Me.日期_Label.Caption = "季度"
Me.Label62.Caption = "《帐务统计报表_按季》"
Case 4
sjTJRQXX = "Format([日期],'yyyy年')"
Me.日期_Label.Caption = "年度"
Me.Label62.Caption = "《帐务统计报表_按年》"
Case Else
sjTJRQXX = "Format([日期],'yyyy年mm月份')"
Me.日期_Label.Caption = "月份"
Me.Label62.Caption = "《帐务统计报表_按月》"
End Select
Me.RecordSource = "Select " & sjTJRQXX & " AS 统计日期, Count(帐务资料表.主帐ID) AS 笔数, Sum(帐务资料表.金额) AS 金额统计, Sum(帐务资料表.成本) AS 成本统计, Sum(帐务资料表.利润) AS 利润统计 FROM 帐务资料表" & sjCXtj & " GROUP BY " & sjTJRQXX & ";"
End If
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access快速开发平台--对上传...(11.22)
- Access快速开发平台企业版--...(11.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)
- 微软Access邀测新Monaco...(11.12)
- Access列表框左右互选、列表框...(11.11)
- 高效率在导入数据前删除记录(11.10)
- Access报价单转订单示例代码(11.08)
- Access系统自带的日期选择器不...(11.08)