943,753 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Oct 18th, 2008
0

Sorting a .mdb database by date?

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Entropy1024 is offline Offline
20 posts
since Oct 2008
Oct 18th, 2008
0

Re: Sorting a .mdb database by date?

Hi,

if Your date column name is mdate, you have to slect the data as

RecordSourse = "Select * from AdHocData Order By mdate"

This would surely select the data as the order of date. If not correct for your computer, ssend your data to the forum and let me check.
Reputation Points: 10
Solved Threads: 4
Light Poster
K.Vanlalliana is offline Offline
44 posts
since Jul 2008
Oct 18th, 2008
0

Re: Sorting a .mdb database by date?

The date field is StartDateTime and I have added:-

Select * from AdHocData Order By StartDateTime

To the RecordSource line but it still does not sort via date order.

Please find attached the database.

Many thanks
Attached Files
File Type: zip AdHocData.zip (7.5 KB, 55 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Entropy1024 is offline Offline
20 posts
since Oct 2008
Oct 18th, 2008
0

Re: Sorting a .mdb database by date?

donot use DATE as a field name ,that is a datatype in database .
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Oct 18th, 2008
0

Re: Sorting a .mdb database by date?

So it won't work because I used the field name StartDateTime?

I can understand it not liking just 'Date' but find it extremely odd that it does not like the above.

Is it possible to rename my StartDateTime filed to something else, say 'SDT' without it erasing all the data in the database?

Cheers
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Entropy1024 is offline Offline
20 posts
since Oct 2008
Oct 19th, 2008
0

Re: Sorting a .mdb database by date?

you can do that in acess.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Oct 19th, 2008
0

Re: Sorting a .mdb database by date?

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
Reputation Points: 10
Solved Threads: 4
Light Poster
K.Vanlalliana is offline Offline
44 posts
since Jul 2008
Oct 20th, 2008
0

Re: Sorting a .mdb database by date?

Maybe the date column was already sorted...

Anyway, what type is your date declared? is it a date or text?
Last edited by jireh; Oct 20th, 2008 at 8:23 am.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Oct 22nd, 2008
0

Re: Sorting a .mdb database by date?

Click to Expand / Collapse  Quote originally posted by jireh ...
Maybe the date column was already sorted...

Anyway, what type is your date declared? is it a date or text?
The date is stored as a text field in the database.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Entropy1024 is offline Offline
20 posts
since Oct 2008
Oct 22nd, 2008
0

Re: Sorting a .mdb database by date?

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.
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007

This thread is more than three months old

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.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Wave In/out APIs
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Database Grid View BUT WHICH ONE???





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC