设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[帮助] 按日期查询问题

[复制链接]
1#
发表于 2013-6-5 09:35:53 | 显示全部楼层
本帖最后由 li_wanli 于 2013-6-5 09:37 编辑

在"按日期查询"(query)添加单击事件
Private Sub query_Click()
On Error GoTo Err_query_Click
    Dim strWhere As String
    strWhere = ""
    If Not IsNull(Me.开始日期) Then
        strWhere = strWhere & "([日期] >= #" & Format(Me.开始日期, "yyyy-mm-dd") & "#) AND "
    End If
    If Not IsNull(Me.截止日期) Then
        strWhere = strWhere & "([日期] <= #" & Format(Me.截止日期, "yyyy-mm-dd") & "#) AND "
    End If
    If Len(strWhere) > 0 Then
        strWhere = Left(strWhere, Len(strWhere) - 5)
    End If
    Me.Form.Filter = strWhere
    Me.Form.FilterOn = True
Exit_query_Click:
    Exit Sub
Err_query_Click:
    MsgBox Err.Description
    Resume Exit_query_Click
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-6 12:06 , Processed in 0.104864 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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