Between And in SQL Statement

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
 
K

Ken Snell

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 & "#")
 
P

Phil Hunt

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 & "#")
 
G

Guest

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>




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top