Between And in SQL Statement

  • Thread starter Thread starter Linda
  • Start date Start date
L

Linda

I,m using the following statment to limit my recordset:

Dim vardatebeg, vardateend as variant

Set rstin = dbs.OpenRecordset("Select * From tblAllDates
Where CallDate Between #varDateBeg# And #varDateEnd#")

When debugging I,m getting the follwing error message:

syntax error in date in query expression.
Can anyone see what I'm doing wrong here? TIA
 
Assuming that varDateBeg and varDateEnd are variables, concatenate their
values into the string outside the string:

Set rstin = dbs.OpenRecordset("Select * From tblAllDates Where CallDate
Between #" & varDateBeg & "# And #" & varDateEnd & "#")
 
try copy and paste the following, basically you need to suround the dates
with quoute
Set rstin = dbs.OpenRecordset("Select * From tblAllDates
Where CallDate Between #" & varDateBeg & "# And #" & varDateEnd & "#")
 
Thanks guys!!
-----Original Message-----
Assuming that varDateBeg and varDateEnd are variables, concatenate their
values into the string outside the string:

Set rstin = dbs.OpenRecordset("Select * From tblAllDates Where CallDate
Between #" & varDateBeg & "# And #" & varDateEnd & "#")


--
Ken Snell
<MS ACCESS MVP>




.
 
Back
Top