Using CVDate and Between And operator in SQL select statement

G

Guest

I'm trying to create an sql statement based on 2 dates that have to be
entered in 2 unbound fields on a form.

I'm building the sql select statement with cvdate and the bewteen and
operators.

strsql = "SELECT Ponr, DateSigned "
strsql = strsql + "FROM tblMain "
strsql = strsql + "WHERE DateSigned Between CVDate(txtbegin) And
CVDate(txtend)"

DoCmd.runsql strsql

When running the routine, it stops ate the sql line where I use the Where
clause.
I'm getting a syntax error message.
Does anyone see what I'm doing wrong here? Thanks.
 
G

Guest

Try this line instead
strsql = strsql + "WHERE DateSigned Between #" & CDate(txtbegin) & "# And #" &
CDate(txtend) & "#"
 

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