DTPicker control

leemin
11-14-2000, 01:01 AM
Hi,

Can someone tell me what is the data type of DTPicker control. I tried using 'valtype' and it said Date.
But I can't seem to be able to extract a recordset based on date range.
This is my code:

Adodc2.RecordSource = "SELECT Ta_ITEMTRN.CODE, Ta_ITEMTRN.TRNDATE, " & _
"FROM Ta_ITEMTRN WHERE Ta_ITEMTRN.CODE='" & itemcode.BoundText & "' " & _
"Ta_ITEMTRN.TRNDATE>=#" & Ctl_sdate & "# AND Ta_ITEMTRN<=#" & Ctl_edate & "#"
Ctl_sdate and Ctl_edate are DTPicker control.
When it's run, it just pull all records belong to ta_itemtrn.code instead of what I want.
Can someone help ?

PWNettle
11-14-2000, 03:46 PM
You might wrap your date picker values with CDate() just to make sure the values are converted to a date that your system likes. You might also specify Ctl_sdate.Value or whatever property it is that returns the date value of the control.

You don't mention your database type. If it's Access, then wrapping your dates with '#' is the way to go, if it's SQL Server you should wrap your dates with single quotes instead of pound signs.

Good luck,
Paul

leemin
11-16-2000, 11:36 PM
hi Paul,

I'd tried the cdate() before but it does work, nothing was extracted.
by the way, my database is access 2000 format.
strange thing is when I use '#', it extract records up till the Ctl_edate but it also include records that is before Ctl_sdate. In other words, it basically pull out 1st record to the Ctl_edate.

leemin
11-16-2000, 11:38 PM
sorry, there is a typo mistake in my earlier message:

Using CDate does NOT work.

PWNettle
11-17-2000, 10:10 AM
How about this... In your SQL statement you have:

"Ta_ITEMTRN.TRNDATE>=#" & Ctl_sdate & "# AND Ta_ITEMTRN<=#" & Ctl_edate & "#"

and shouldn't it read:

"Ta_ITEMTRN.TRNDATE>=#" & Ctl_sdate & "# AND Ta_ITEMTRN.TRNDATE<=#" & Ctl_edate & "#"

It looks like you left the .TRNDATE off the second compare. Coulda been a typo in your post. I'm not sure if the SQL statement would work at all as written but I don't use Access 2000.

Maybe?

Paul

leemin
11-20-2000, 09:30 PM
paul, you're right, it was a typo too, not in my code but in my message.
Theorically it should work but it just wouldn't give me what I want.
oh god, it's driving me nuts.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum