Dim myDate As Date
myDate = CDate(Date)
SQL = " Select Count(PONumber) As OverDue from tblPO where POExpireDate < '" & myDate & "'"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL)
我正在运行此代码...。在OpenRecordset中,它显示错误...
条件表达式中的数据类型不匹配。
我现在该怎么办...为什么会出现此错误?
答案 0 :(得分:1)
由于Date
返回当前日期,因此您只需在SQL中直接使用Date()
:
SQL = "Select Count(PONumber) As OverDue from tblPO where POExpireDate < Date()"