-
here's my code:
Set rs1 = adconn.Execute("SELECT * from ApplDetail where appr = true and level1 = false and apprdate >= " & DTPicker1.Value)
apprdate is a date type data, in Access.
however, i failed to compare it with my DateTimePicker's value... it doesn't return the expected result.
the rs1 recordset is to be retrieved by a DataReport, so only SQL statements can be used...
can you help me this time?
thanks.
Yih
-
The problem probably is that you date from your db isn't the same format as the date from your dtpicker. You must make them the same format with the Format function :
Dim tempDate as date
tempDate = format(DTPicker1.value,"dd/mm/yy")
Then your comparison...
' Off course the format must be the same as the format you use in Access. It could also be mm/dd/yy or something else.
-
lingtze, it because you miss out the "#" sign. For date in database, you must include the "#" at both end of the Date datatype.
Code:
Set rs1 = adconn.Execute("SELECT * from ApplDetail where appr = true and level1 = false and apprdate >= #" & DTPicker1.Value & "#);"