Question On SQL Syntax

D

David

Does anyone know the correct syntax:

This syntax works when hardcoding the dates:
strDistinct = "Select * from qryToDistrictDistinct where
ToDistrict Between #09/01/2003# And #09/30/2003#"

but...I would like to refer to a values on a form like
this:

strDistinct = "Select * from qryToDistrictDistinct where
ToDistrict Between #Me.dtStart# And #Me.dtEnd#"
but...it does not work

Any solutions?
 
D

Dirk Goldgar

David said:
Does anyone know the correct syntax:

This syntax works when hardcoding the dates:
strDistinct = "Select * from qryToDistrictDistinct where
ToDistrict Between #09/01/2003# And #09/30/2003#"

but...I would like to refer to a values on a form like
this:

strDistinct = "Select * from qryToDistrictDistinct where
ToDistrict Between #Me.dtStart# And #Me.dtEnd#"
but...it does not work

Any solutions?

Here's one:

strDistinct = _
"SELECT * FROM qryToDistrictDistinct " & _
"WHERE ToDistrict Between " & _
Format(Me.dtStart, "\#mm/dd/yyyy\#") & _
" And " _
Format(Me.dtEnd, "\#mm/dd/yyyy\#")
 

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