JackCrackers
Registered User.
- Local time
- Today, 12:37
- Joined
- Apr 17, 2009
- Messages
- 13
Hello
I am writing a program in VB 6.0 using a Access mdb database file. I am trying to retrieve records from a table, where the date of the records falls between 2 given dates from a record in a different table. The code is returning the wrong records. this is an example of the data:
tblResults Reindx ReCn ReCh RePDate RePactv RePrumm ReInt ReHl ReSDate ReEDate ReStatus ReBDate ReDays 16 87 87.01 09/03/2012 22:00:00 100 -49
20 09/03/2012 14:00:00 10/03/2012 08:00:00 Bred 09/03/2012 0
tblRLine RLIndx RLCn RLDate RLTime RLAc RLRm RLLs RLDays RLdateTime 66 87 09/03/2012 14:00:00 31 -6 Bred 0 09/03/2012 14:00:00 67 87 09/03/2012 16:00:00 66 -13 Bred 0 09/03/2012 16:00:00 68 87 09/03/2012 18:00:00 85 -15 Bred 0 09/03/2012 18:00:00 69 87 09/03/2012 20:00:00 90 -22 Bred 0 09/03/2012 20:00:00 70 87 09/03/2012 22:00:00 100 -21 Bred 0 09/03/2012 22:00:00 71 87 10/03/2012 00:00:00 97 -34 Bred 0 10/03/2012 72 87 10/03/2012 02:00:00 96 -49 Bred 0 10/03/2012 02:00:00 73 87 10/03/2012 04:00:00 93 -26 Bred 0 10/03/2012 04:00:00 74 87 10/03/2012 06:00:00 84 -36 Bred 0 10/03/2012 06:00:00 75 87 10/03/2012 08:00:00 81 -17 Bred 0 10/03/2012 08:00:00 76 87 04/07/2012 12:00:00 36 -20 Pregnant 116 04/07/2012 12:00:00 77 87 04/07/2012 14:00:00 54 -21 Pregnant 116 04/07/2012 14:00:00 78 87 04/07/2012 16:00:00 49 -19 Pregnant 116 04/07/2012 16:00:00 79 87 04/07/2012 18:00:00 30 -19 Pregnant 116 04/07/2012 18:00:00 80 87 25/07/2012 02:00:00 63 -21 Pregnant 137 25/07/2012 02:00:00 81 87 25/07/2012 04:00:00 82 -31 Pregnant 137 25/07/2012 04:00:00 82 87 25/07/2012 06:00:00 79 -47 Pregnant 137 25/07/2012 06:00:00 83 87 25/07/2012 08:00:00 67 -54 Pregnant 137 25/07/2012 08:00:00 84 87 25/07/2012 10:00:00 60 -34 Pregnant 137 25/07/2012 10:00:00 85 87 02/09/2012 02:00:00 43 8 Open and No Heat 176 02/09/2012 02:00:00 86 87 02/09/2012 04:00:00 73 4 Open and No Heat 176 02/09/2012 04:00:00 87 87 02/09/2012 06:00:00 84 2 Open and No Heat 176 02/09/2012 06:00:00 88 87 02/09/2012 08:00:00 88 -5 Open and No Heat 176 02/09/2012 08:00:00 89 87 02/09/2012 10:00:00 86 -7 Open and No Heat 176 02/09/2012 10:00:00 90 87 02/09/2012 12:00:00 81 -9 Open and No Heat 176 02/09/2012 12:00:00 91 87 02/09/2012 14:00:00 69 -10 Open and No Heat 176 02/09/2012 14:00:00 92 87 02/09/2012 16:00:00 38 -15 Open and No Heat 176 02/09/2012 16:00:00 93 87 29/09/2012 18:00:00 43 -25 Open and No Heat 203 29/09/2012 18:00:00 94 87 29/09/2012 20:00:00 47 -28 Open and No Heat 203 29/09/2012 20:00:00 95 87 29/09/2012 22:00:00 47 -23 Open and No Heat 203 29/09/2012 22:00:00 96 87 30/09/2012 00:00:00 79 -17 Open and No Heat 204 30/09/2012
Here is the code
This code is meant to return records from tblRlines that have dates between tblresults!resdate and tblresults!reedate that is between
tblResults ReSDate 09/03/2012 14:00:00
and
tblResults ReEDate 10/03/2012 08:00:00
There are 10 such records in tblRline from key index=66 until key index =77
Instead 5 records are returned between the dates
tblRLine RLdateTime 29/09/2012 18:00:00
and
tblRLine RLdateTime 30/09/2012 02:00:00
The string used to get the records from tblRlines looks like this :
select * from tblrline where (tblrline.rldatetime>=#09/03/2012 14:00:00#) and (tblrline.rldatetime<=#10/03/2012 08:00:00#) and (tblrline.rlcn=87)
I can't find my mistake
Thank you
John
I am writing a program in VB 6.0 using a Access mdb database file. I am trying to retrieve records from a table, where the date of the records falls between 2 given dates from a record in a different table. The code is returning the wrong records. this is an example of the data:
tblResults Reindx ReCn ReCh RePDate RePactv RePrumm ReInt ReHl ReSDate ReEDate ReStatus ReBDate ReDays 16 87 87.01 09/03/2012 22:00:00 100 -49
20 09/03/2012 14:00:00 10/03/2012 08:00:00 Bred 09/03/2012 0
tblRLine RLIndx RLCn RLDate RLTime RLAc RLRm RLLs RLDays RLdateTime 66 87 09/03/2012 14:00:00 31 -6 Bred 0 09/03/2012 14:00:00 67 87 09/03/2012 16:00:00 66 -13 Bred 0 09/03/2012 16:00:00 68 87 09/03/2012 18:00:00 85 -15 Bred 0 09/03/2012 18:00:00 69 87 09/03/2012 20:00:00 90 -22 Bred 0 09/03/2012 20:00:00 70 87 09/03/2012 22:00:00 100 -21 Bred 0 09/03/2012 22:00:00 71 87 10/03/2012 00:00:00 97 -34 Bred 0 10/03/2012 72 87 10/03/2012 02:00:00 96 -49 Bred 0 10/03/2012 02:00:00 73 87 10/03/2012 04:00:00 93 -26 Bred 0 10/03/2012 04:00:00 74 87 10/03/2012 06:00:00 84 -36 Bred 0 10/03/2012 06:00:00 75 87 10/03/2012 08:00:00 81 -17 Bred 0 10/03/2012 08:00:00 76 87 04/07/2012 12:00:00 36 -20 Pregnant 116 04/07/2012 12:00:00 77 87 04/07/2012 14:00:00 54 -21 Pregnant 116 04/07/2012 14:00:00 78 87 04/07/2012 16:00:00 49 -19 Pregnant 116 04/07/2012 16:00:00 79 87 04/07/2012 18:00:00 30 -19 Pregnant 116 04/07/2012 18:00:00 80 87 25/07/2012 02:00:00 63 -21 Pregnant 137 25/07/2012 02:00:00 81 87 25/07/2012 04:00:00 82 -31 Pregnant 137 25/07/2012 04:00:00 82 87 25/07/2012 06:00:00 79 -47 Pregnant 137 25/07/2012 06:00:00 83 87 25/07/2012 08:00:00 67 -54 Pregnant 137 25/07/2012 08:00:00 84 87 25/07/2012 10:00:00 60 -34 Pregnant 137 25/07/2012 10:00:00 85 87 02/09/2012 02:00:00 43 8 Open and No Heat 176 02/09/2012 02:00:00 86 87 02/09/2012 04:00:00 73 4 Open and No Heat 176 02/09/2012 04:00:00 87 87 02/09/2012 06:00:00 84 2 Open and No Heat 176 02/09/2012 06:00:00 88 87 02/09/2012 08:00:00 88 -5 Open and No Heat 176 02/09/2012 08:00:00 89 87 02/09/2012 10:00:00 86 -7 Open and No Heat 176 02/09/2012 10:00:00 90 87 02/09/2012 12:00:00 81 -9 Open and No Heat 176 02/09/2012 12:00:00 91 87 02/09/2012 14:00:00 69 -10 Open and No Heat 176 02/09/2012 14:00:00 92 87 02/09/2012 16:00:00 38 -15 Open and No Heat 176 02/09/2012 16:00:00 93 87 29/09/2012 18:00:00 43 -25 Open and No Heat 203 29/09/2012 18:00:00 94 87 29/09/2012 20:00:00 47 -28 Open and No Heat 203 29/09/2012 20:00:00 95 87 29/09/2012 22:00:00 47 -23 Open and No Heat 203 29/09/2012 22:00:00 96 87 30/09/2012 00:00:00 79 -17 Open and No Heat 204 30/09/2012
Here is the code
Code:
ssql = "select * from tblrline where (tblrline.rldatetime>=" & "#" & rstemp!resdate & "#" & ") and (tblrline.rldatetime<=" & "#" & rstemp!reedate & "#) and (tblrline.rlcn=" & thiscow& & ")"
With rstemp1
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.ActiveConnection = cn1
.Source = ssql
.Open
End With
This code is meant to return records from tblRlines that have dates between tblresults!resdate and tblresults!reedate that is between
tblResults ReSDate 09/03/2012 14:00:00
and
tblResults ReEDate 10/03/2012 08:00:00
There are 10 such records in tblRline from key index=66 until key index =77
Instead 5 records are returned between the dates
tblRLine RLdateTime 29/09/2012 18:00:00
and
tblRLine RLdateTime 30/09/2012 02:00:00
The string used to get the records from tblRlines looks like this :
select * from tblrline where (tblrline.rldatetime>=#09/03/2012 14:00:00#) and (tblrline.rldatetime<=#10/03/2012 08:00:00#) and (tblrline.rlcn=87)
I can't find my mistake
Thank you
John