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.
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")
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.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline:Wave In/out APIs