Question On SQL Syntax

  • Thread starter Thread starter David
  • Start date Start date
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?
 
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\#")
 
Back
Top