I need to set a SQL statement to retrieve all records for the last 10 days only.
I have tried this:
But I keep getting an error: "No value given for one or more required parameters".
The code works if I make the following change:
So I know it's in the date calculation part of my SQL. But I can't figure out how to incorporate a DateAdd into my sql. Any ideas?
Thanks!
I have tried this:
Code:
Dim RS As New ADODB.Recordset
TenDaysAgo = Format(DateAdd("d", -10, Now), "Short Date")
strSQL = "SELECT * FROM [Wreckers] WHERE [WreckerDate] > #" & TenDaysAgo & "#"
RS.Open strSQL, CurrentProject.Connection, adOpenStatic, adLockBatchOptimistic
But I keep getting an error: "No value given for one or more required parameters".
The code works if I make the following change:
Code:
strSQL = "SELECT * FROM [Wreckers]" ' WHERE [WreckerDate] > #" & TenDaysAgo & "#"
So I know it's in the date calculation part of my SQL. But I can't figure out how to incorporate a DateAdd into my sql. Any ideas?
Thanks!