| | |
Sorting a .mdb database by date?
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2008
Posts: 20
Reputation:
Solved Threads: 0
I have a .mdb database that contains various records. One of the fields is date, ie '19/10/2008 00:00'.
How do I sort the database by date?
I an a beginner and currently learning with the 'Visual Basic in easy steps' by Tim Anderson. On page 104 he has an example database called 'Members'. To sort by surname he says to do the following:-
RecordSet = 1-Dynaset
RecordSource = Select * from Members Order By LastName
This then sorts the 'Members' database by Surnames.
So I would have thought that if I set my database 'AdHocData' to:
RecordSet = 1-Dynaset
RecordSourse = Select * from AdHocData Order By Date
this would re-arrange the database by date, but it appears to have no effect.
Can anyone please tell me where I am going wrong?
Many thanks.
How do I sort the database by date?
I an a beginner and currently learning with the 'Visual Basic in easy steps' by Tim Anderson. On page 104 he has an example database called 'Members'. To sort by surname he says to do the following:-
RecordSet = 1-Dynaset
RecordSource = Select * from Members Order By LastName
This then sorts the 'Members' database by Surnames.
So I would have thought that if I set my database 'AdHocData' to:
RecordSet = 1-Dynaset
RecordSourse = Select * from AdHocData Order By Date
this would re-arrange the database by date, but it appears to have no effect.
Can anyone please tell me where I am going wrong?
Many thanks.
•
•
Join Date: Jul 2008
Posts: 44
Reputation:
Solved Threads: 3
Hi,
I used select text for the date filed so that the date can always be displayed with the format you like / exspected and that is not effected by date format selected in the control pannel. For the order of date, please make another field like 'dval' in which the value of date will be store like this:
2-March-2008 is stored as 20080302
This can be done by using formatting code Format(2-march-2008,"yyyymmdd")
KVL
I used select text for the date filed so that the date can always be displayed with the format you like / exspected and that is not effected by date format selected in the control pannel. For the order of date, please make another field like 'dval' in which the value of date will be store like this:
2-March-2008 is stored as 20080302
This can be done by using formatting code Format(2-march-2008,"yyyymmdd")
KVL
Maybe the date column was already sorted...
Anyway, what type is your date declared? is it a date or text?
Anyway, what type is your date declared? is it a date or text?
Last edited by jireh; Oct 20th, 2008 at 8:23 am.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
I see that's why your sorting of date doesn't work because it sorts out according to string or text... please change the data type to date or datetime.
Last edited by jireh; Oct 22nd, 2008 at 8:19 am.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Wave In/out APIs
- Next Thread: Database Grid View BUT WHICH ONE???
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






