Results 1 to 4 of 4
  1. #1
    slikbaz is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    1

    Sorting a form's records in order by date.

    Hi,

    Basically I have a form which displays data that is stored in a table. One of the fields that is displayed has dates entered into it. Now I need a button which, when clicked, sorts the records in the form into ascending/descending order from the earliest date to the latest.

    A similar problem was solved here:

    http://www.tek-tips.com/viewthread.c...343020&page=86



    However when I tried that, it only works for text-based fields and not for dates.

    Also, I was wondering how to sort numbers into order, from lowest to highest and highest to lowest with no negative numbers present.

    Any help appreciated

    Slikbaz

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    here is a small example I have a table called valueTable with a Date Field LDate. I have attached this piece of code to the OnClick event of a Command button to Filter my Form in the assending Order of date. I have used strSQl as the Record source to sort the form by LDate.

    Dim strSQL As String
    strSQL = "Select * From valueTable Order By LDate"
    Me.RecordSource = strSQL

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    can't you do it by me.orderBy ?
    e.g.
    me.orderBy="MyDate asc"
    me.orderbyon=true

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Absolutely it can be done by using me.orderBy. In fact I think is much more easier that way.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  2. Replies: 7
    Last Post: 10-20-2010, 04:08 PM
  3. How to use Rnd to order records?
    By Gdm in forum Queries
    Replies: 1
    Last Post: 05-26-2010, 09:01 PM
  4. Date Sorting
    By sfoot0309 in forum Queries
    Replies: 1
    Last Post: 04-25-2010, 09:59 PM
  5. Sorting By Date!
    By Pirate in forum Access
    Replies: 0
    Last Post: 07-19-2007, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums