calendar date, strings and SQL

P

pdunn

Hello, I am a major minor problem.
I am getting the date from the calendar control to pass through to SQL to
return certain rows.

The SQL function works with me typing in
strSQL = "Select * from Table Where sDate = ""09/10/2008"""

However using,
Dim dtDate as Date
dtDate = Me.Calender0.value
strSQL = "Select * from Table Where sDate = ""
strSQL = strSQL & CStr(dtDate) & """

nor excluding CStr() works

when testing
if CStr(dtDate) = "09/10/2008" then msgbox(something) end if

the msgbox does not appear

on a side note, using strCompare seems to state they are equal.

any help with being able to get a value from a Calendar control and place it
into a sql statement to access a database would be helpful. Also,
parameterized query MIGHT be helpful, but I am just exploring any options.

Thank you,

PDunn
 
P

pietlinden

strSQL = "Select * from Table Where sDate = ""09/10/2008"""

the normal delimiter for dates in Access SQL is #, so try this:

strSQL = "Select * from Table Where sDate = #09/10/2008#
 

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