Results 1 to 6 of 6
  1. #1
    1337noob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    4

    Sorting problem

    I can't figure out how to get the data sorted the way it needs to be. this is what it needs to look like:

    1
    2
    3
    10


    20
    300
    1000
    1000a
    1000b
    2000
    2000.1
    2000.2
    2000.2.3
    2000b.2.4
    3000
    Alpha
    Beta
    Charlie
    Cook
    Delta

    any help would be appreciated. thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Numbers in a text field sort by alpha, not numeric. So 12 will sort before 9. Need placeholder zeros prefix.

    0001
    0020
    0300
    1000
    1000a
    2000.2.3
    2000b.2.4
    Alpha
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    1337noob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    4
    thats the thing the data cannot have leading zeroes

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Then create field in query with an expression that can be used as the sort criteria. Based on the sample provided, try this: IIf(Val([fieldname])<1000,Format([fieldname],"0000"),[fieldname])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    1337noob is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    4
    Quote Originally Posted by June7 View Post
    Then create field in query with an expression that can be used as the sort criteria. Based on the sample provided, try this: IIf(Val([fieldname])<1000,Format([fieldname],"0000"),[fieldname])
    Please excuse my inexperience, but how do I do this?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Query in design view, on the Field row type the suggested expression, give it whatever name you want, like:

    SortID: IIf(Val([fieldname])<1000,Format([fieldname],"0000"),[fieldname])

    Then in the OrderBy row select ASCEN.

    Expressions in queries is basic Access functionality. Google for tutorials.

    There is an expression builder wizard but I seldom use it: http://msdn.microsoft.com/en-us/library/gg241307.aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Problem sorting date on query
    By system243trd in forum Queries
    Replies: 4
    Last Post: 12-02-2011, 01:05 PM
  2. Sorting by combobox problem
    By wsurritte in forum Access
    Replies: 11
    Last Post: 02-28-2011, 02:11 PM
  3. Replies: 10
    Last Post: 12-21-2010, 12:41 PM
  4. report formating/sorting problem
    By bill4364 in forum Reports
    Replies: 1
    Last Post: 02-19-2010, 08:15 PM
  5. Is this a Query or Sorting problem?
    By bwrobel in forum Queries
    Replies: 2
    Last Post: 07-14-2006, 08:15 AM

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