Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Statement Problem

Status
Not open for further replies.

judyscofield

Programmer
Sep 24, 2001
56
US
I'm trying to open a recordset in VB against a SQL Server Database. The criteria field is a datetime field in the table. I'm testing with two records, one with a date of 12/20/2002 and the other 1/10/2003.

A date is entered in a maskedit box on a form. If I enter the value 01/01/2003 as the date to use in the select statement. I should get a recordset with 1 record, but I keep getting both records.

rsvisits.open "select * from jovisit " & _
"where jovdate > " & cdate(mskvdate.text) & _
" order by jovdate"

I also want a similar statement using two dates and between, but I then get no records returned.

Am I coding this wrong?

Thanks

Judy Scofield
 
Try

rsvisits.open "select * from jovisit " & _
"where jovdate > '" & format(cdate(mskvdate.text),"mm/dd/yyyy") & _
"' order by jovdate"

cjw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top