设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 3651|回复: 7
打印 上一主题 下一主题

[Access本身] 关于筛选时间区间的语句?

[复制链接]
跳转到指定楼层
1#
发表于 2006-9-14 22:37:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Dim strWhere As String
Dim sdate As Date
strWhere = ""
If Not IsNull(Me.month) Then
strWhere = strWhere & "([month] like '*" & Me.Month & "*') AND "----这里想用交易日期来筛选 例如:[trx_dt] in 起始日期 to 结束日期 . 起始日期和结束日期为文本框。用语句是怎么来表示的,试了半天都没试出来!
End If
If Not IsNull(Me.Trx_type) Then
strWhere = strWhere & "([trx_type] like '*" & Left(Me.Trx_type, 1) & "*') and "
End If
If Not IsNull(Me.wx_no) Then
strWhere = strWhere & "([wx_no] like '*" & Me.wx_no & "*') and "
End If
If Not IsNull(Me.Vend_no) Then
strWhere = strWhere & "([vend_no] like '*" & Me.Vend_no & "*') and "
End If

   If Len(strWhere) > 0 Then
        strWhere = Left(strWhere, Len(strWhere) - 5)
    End If
Me.交易明细_子窗体.Form.Filter = strWhere
Me.交易明细_子窗体.Form.FilterOn = True

[此贴子已经被作者于2006-9-14 14:38:42编辑过]

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2006-9-14 22:59:00 | 只看该作者
trx_dt>=#" & CDate(起始日期 ) & "#" and trx_dt<= #" & CDate(结束日期) & "#"
3#
 楼主| 发表于 2006-9-15 05:34:00 | 只看该作者
我刚才试了下,在 第三个 “#”的地方报错!

By the way,学Access也有会了,唯一让人困惑的就是Access的格式真麻烦!特别是(‘’-单引号,“”-双引号,&&-与,还有表的引用,真是麻烦啊,有没有总结性的帖子啊?)
4#
发表于 2006-9-15 05:52:00 | 只看该作者
我自已用的好好的,你把完整的贴上来
5#
 楼主| 发表于 2006-9-15 06:06:00 | 只看该作者
strWhere = ""
If Not IsNull(Me.Beg_dt) Then
strWhere = strWhere & "([trx_dt]>= #" & CDate( me.Beg_dt ) & "#" and [trx_dt]>= #" & CDate( me.Beg_dt  ) & "#" ) AND "
End If

这么写对么?我这上传不方便,将就着给我诊一下吧……
6#
发表于 2006-9-15 06:37:00 | 只看该作者
strWhere = strWhere & "([trx_dt] >= #" & CDate(Me.起始日期) & "#) and ([trx_dt] <= #" & CDate(Me.结束日期) & "#) AND "
7#
发表于 2006-9-15 06:37:00 | 只看该作者
以下是引用wonderfeng在2006-9-14 22:06:00的发言:


strWhere = ""
If Not IsNull(Me.Beg_dt) Then
strWhere = strWhere & "([trx_dt]>= #" & CDate( me.Beg_dt ) & "#" and [trx_dt]>= #" & CDate( me.Beg_dt  ) & "#" ) AND "
End If

这么写对么?我这上传不方便,将就着给我诊一下吧……

有什么不方便的?将例子简化一下就行了,你不会程序还没有做好就登记了重要资料吧
8#
 楼主| 发表于 2006-9-15 16:48:00 | 只看该作者
以下是引用一点通在2006-9-14 22:37:00的发言:



有什么不方便的?将例子简化一下就行了,你不会程序还没有做好就登记了重要资料吧



昨天晚上是在家里的,家里Access用不起来了,故不方便

谢谢Andymark!

对了,关于格式的总结帖有么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-30 02:30 , Processed in 0.180072 second(s), 31 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表