Office中国论坛/Access中国论坛
标题:
关于用vba实现日期比较
[打印本页]
作者:
access_lerner
时间:
2005-9-28 09:13
标题:
关于用vba实现日期比较
我想用下面这段代码完成在某段日期范围内查找数据的功能。 但是不知为什么无法实现。 请高手帮忙看一下。 谢谢![em17][em17]
If IsDate(Me.OpenedDateFrom) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Issues.[Opened Date] >= " & GetDateFilter(Me.OpenedDateFrom)
ElseIf Nz(Me.OpenedDateFrom) <> "" Then
strError = cInvalidDateError
End If
' If Opened Date To
If IsDate(Me.OpenedDateTo) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "Issues.[Opened Date] <= " & GetDateFilter(Me.OpenedDateTo)
ElseIf Nz(Me.OpenedDateTo) <> "" Then
strError = cInvalidDateError
End If
-----------------------------------------------------------------------------------------
Function GetDateFilter(dtDate As Date) As String
' Date filters must be in MM/DD/YYYY format
GetDateFilter = "#" & Format(dtDate, "MM/DD/YYYY hh:mm:ss AM/PM") & "#"
End Function
作者:
海狸先生
时间:
2005-9-28 17:31
最好把完整的代码或文件发上来
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3