日期起止值全方位计算
时 间:2009-03-01 21:41:16
作 者:沈军 ID:2469 城市:东莞
摘 要:这里总结了一下师傅们知识,有时候需要在某查询中提高日期范围选择速度,应该对日常工作有所帮助.
正 文:
'1;今年;2;这个月;3;上个月;4;去年;5;所有;6;今年上半年;7;今年下半年;8;今年一季度;9;今年二季度;10;今年三季度;11;今年四季度;12;去年一季度;13;去年二季度;14;去年三季度;15;去年四季度
Select Case Me.Combo10
Case 1
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
Case 2
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()), 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()) + 1, 0)"
Case 3
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), Month(Now())-1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()), 0)"
Case 4
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())-0, 1, 0)"
Case 5
Me.开始日期.ControlSource = "=DMIN('日期','明细帐务资料')"
Me.结束日期.ControlSource = "=DMAX('日期','明细帐务资料')"
Case 6
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
Case 7
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
Case 8
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 4, 0)"
Case 9
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 4, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
Case 10
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 10, 0)"
Case 11
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 10, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
'12;去年一季度;13;去年二季度;14;去年三季度;15;去年四季度;16;去年上半年;17;去年下半年;
Case 12
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 4, 0)"
Case 13
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 4, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 0)"
Case 14
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 10, 0)"
Case 15
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 10, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 1, 0)"
Case 16
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 0)"
Case 17
Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 1, 0)"
'20;今年1月份;21;今年2月份;22;今年3月份;23;今年4月份;24;今年5月份;25;今年6月份;26;今年7月份;27;今年8月份;28;今年9月份;29;今年10月份;30;今年11月份;31;今年12月份;
Case 20
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 2, 0)"
Case 21
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 2, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 3, 0)"
Case 22
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 3, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 4, 0)"
Case 23
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 4, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 5, 0)"
Case 24
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 5, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 6, 0)"
Case 25
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 6, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
Case 26
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 8, 0)"
Case 27
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 8, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 9, 0)"
Case 28
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 9, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 10, 0)"
Case 29
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 10, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 11, 0)"
Case 30
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 11, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 12, 0)"
Case 31
Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 12, 1)"
Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
End Select
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.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)
- 微软Access邀测新Monaco...(11.12)
- Access列表框左右互选、列表框...(11.11)
- 高效率在导入数据前删除记录(11.10)
- Access报价单转订单示例代码(11.08)
- Access系统自带的日期选择器不...(11.08)
- 分享一下Access工程中的acw...(11.07)