date trouble

  • Thread starter Thread starter gr
  • Start date Start date
G

gr

Hello!
Can someone tell me what's wrong on this statements pls?

Dim strSQL As String
Dim dtStart As Date
Dim dtEnd As Date

dtStart = CDate(Me!txtStart)
dtEnd = CDate(Me!txtEnd)

strSQL = "Dt Between " & "#" & dtStart & "#" & " And "
& "#" & dtEnd & "#"
stDocName = "rptOther_Admin"
DoCmd.OpenReport stDocName, acPreview, , strSQL

Error Msg: Syntax error in date in query expression '(Dt
Between #01.01.2004# And #10.01.2004#)'.

Thanks
 
It may be complaining about the periods.

Try:

strSQL = "Dt Between " & Format(dtStart, "\#mm\/dd\/yyyy\#") & " And "
& Format(dtEnd, "\#mm\/dd\/yyyy\#")

That will force the format to the US standard.
 
Thank you, Perfect =)
-----Originalnachricht-----
It may be complaining about the periods.

Try:

strSQL = "Dt Between " & Format
(dtStart, "\#mm\/dd\/yyyy\#") & " And "
 
Back
Top