Sorting a .mdb database by date?

Reply

Join Date: Oct 2008
Posts: 20
Reputation: Entropy1024 is an unknown quantity at this point 
Solved Threads: 0
Entropy1024 Entropy1024 is offline Offline
Newbie Poster

Sorting a .mdb database by date?

 
0
  #1
Oct 18th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 44
Reputation: K.Vanlalliana is an unknown quantity at this point 
Solved Threads: 3
K.Vanlalliana K.Vanlalliana is offline Offline
Light Poster

Re: Sorting a .mdb database by date?

 
0
  #2
Oct 18th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 20
Reputation: Entropy1024 is an unknown quantity at this point 
Solved Threads: 0
Entropy1024 Entropy1024 is offline Offline
Newbie Poster

Re: Sorting a .mdb database by date?

 
0
  #3
Oct 18th, 2008
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, 6 views)
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,080
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Sorting a .mdb database by date?

 
0
  #4
Oct 18th, 2008
donot use DATE as a field name ,that is a datatype in database .
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 20
Reputation: Entropy1024 is an unknown quantity at this point 
Solved Threads: 0
Entropy1024 Entropy1024 is offline Offline
Newbie Poster

Re: Sorting a .mdb database by date?

 
0
  #5
Oct 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,080
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 124
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Sorting a .mdb database by date?

 
0
  #6
Oct 19th, 2008
you can do that in acess.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 44
Reputation: K.Vanlalliana is an unknown quantity at this point 
Solved Threads: 3
K.Vanlalliana K.Vanlalliana is offline Offline
Light Poster

Re: Sorting a .mdb database by date?

 
0
  #7
Oct 19th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: Sorting a .mdb database by date?

 
0
  #8
Oct 20th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 20
Reputation: Entropy1024 is an unknown quantity at this point 
Solved Threads: 0
Entropy1024 Entropy1024 is offline Offline
Newbie Poster

Re: Sorting a .mdb database by date?

 
0
  #9
Oct 22nd, 2008
Originally Posted by jireh View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: Sorting a .mdb database by date?

 
0
  #10
Oct 22nd, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC