Rose Jack
Rose Jack

Reputation: 1

Data Type Mismatch in Criteria Expression using Date

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)

Im running this code....at OpenRecordset its shows error...

Data Type Mismatch in Criteria Expression.

What should i do now...why this error Coming?

Upvotes: 0

Views: 55

Answers (1)

Gustav
Gustav

Reputation: 56026

As Date returns the current date, all you need is to use Date() directly in the SQL:

SQL = "Select Count(PONumber) As OverDue from tblPO where POExpireDate < Date()"

Upvotes: 1

Related Questions