Results 1 to 4 of 4
  1. #1
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126

    List Box number sort

    I want to sort by 'PopRank' so that 1, 2, 3 come before 1, 10, 11.
    Pop Rank is formated as a number.

    Code:
     StateList.RowSource = "SELECT [MapID], [State], [Population], [PopRank] FROM StateMapT ORDER BY PopRank;"
    Not sure of the best way to handle this issue with a number sort.

    Thanks


    Jim O

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Sounds like PopRank is a text field, however it may be formatted. I'd correct that, but you can probably work around it with:

    StateList.RowSource = "SELECT [MapID], [State], [Population], [PopRank] FROM StateMapT ORDER BY Format(PopRank, '0000');"

    with the appropriate format.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JimO is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2015
    Posts
    126
    Thank you very much that is what I needed.

    Thanks
    Jim O

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Sort on a fractional number in a text field
    By Exsubsailor in forum Queries
    Replies: 3
    Last Post: 08-30-2017, 08:11 AM
  2. Replies: 4
    Last Post: 10-03-2015, 01:22 AM
  3. Does anyone know how to sort the field list?
    By tstoneami in forum Access
    Replies: 4
    Last Post: 08-08-2013, 12:32 PM
  4. How To Sort A Number Field in a Form?
    By netchie in forum Access
    Replies: 6
    Last Post: 08-02-2012, 10:53 AM
  5. Sort by even or odd number
    By sammer021486 in forum Queries
    Replies: 7
    Last Post: 11-23-2009, 12:30 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