Results 1 to 7 of 7
  1. #1
    BSA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2017
    Posts
    1

    Sorting Alphanumeric Data in a Form

    I am wondering if there is a way to sort this data in the order I would like. I have attached a picture if the current way it sorts but I would like it to go 2W20,2W30,2W35,2W40,2W45,2W50 and so on. Is there a way to do this?
    Attached Thumbnails Attached Thumbnails Feeder Entry Form.PNG  

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Sorting Alphanumeric Data in a Form

    Guess this must be a query for cbobox. Maybe create an expression field in the query to return ending: right([fieldname], Len[fieldname]-3)

    This would return 20,200,30,300,35 etc

    You could then order your combobox on this field.

    Sent from my iPhone using Tapatalk

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    In a select query of your data, make 2 extra fields, a string fld for the text part of the sort :
    SortText:left([field],2)

    And another numeric field,SortNum: cLng(mid(field,3))
    now sort the data on these 2 fields. The numeric fld will sort correctly.

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Snap


    Sent from my iPhone using Tapatalk

  5. #5
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    maybe, but it looks like somewhere in that list is a value that starts with 15-. Not everything appears to begin with a digit followed by one letter.
    clng(Mid("15-3w120",3)) will generate an error. If you can't add a sort field to your table, you'll probably need a more robust code solution. I guess that depends on what the rest of your records look like.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Oops missed the 225L. If there are going to be other letters at the then I agree. A user defined function to extract the left and right ends which can be used in the query of the combobox to sort it seems to be the way forward


    Sent from my iPhone using Tapatalk

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Micron View Post

    ...maybe, but it looks like somewhere in that list is a value that starts with 15-.
    Isn't that a different field than the one being sorted?

    Linq ;0)>

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

Similar Threads

  1. Split alphanumeric field
    By aswin34 in forum Queries
    Replies: 3
    Last Post: 09-11-2015, 08:37 AM
  2. Street Address with alphanumeric
    By ampstar in forum Access
    Replies: 4
    Last Post: 08-07-2014, 11:28 AM
  3. Help with Alphanumeric autonumber
    By RandyP in forum Programming
    Replies: 1
    Last Post: 06-08-2014, 05:38 PM
  4. Sorting by alphanumeric field
    By RonL in forum Access
    Replies: 1
    Last Post: 10-20-2012, 05:06 PM
  5. alphanumeric primary key
    By slimjen in forum Database Design
    Replies: 4
    Last Post: 09-18-2011, 10:20 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