Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorting by Number (A2K)

    One of the fields in my database is "district number" and they range from 1-29. When I view the database in datasheet view and sort the records ascending by the aforementioned field, they order 1,10.....2, 20,...29, 3, 30 and so on. How can I get this to sort numerically??

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sorting by Number (A2K)

    If the field sorts that way, the "district number" must be a text field, despite its name. If it is acceptable to change it to a number field, that would solve your problem. If it isn't, you need to create a query based on your table, and add a calculated field

    DN: CLng([District Number])

    CLng converts the string value to a long integer. You can sort the query on the DN field.

  3. #3
    3 Star Lounger
    Join Date
    May 2003
    Location
    Sacramento, California, USA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting by Number (A2K)

    Thanks, Hans. I can change from text to number- I had a feeling it was that simple, but unfortunately the tables are on a SQL server that I don't have permissions for, and I can only change the front end goodies-so alas, I will have to wait for the administrator to do that for me.

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting by Number (A2K)

    If you can't change the field to numeric, then another possibility is to append a leading zero so tha 1 becomes 01 and 2 becomes 02, etc.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •