Results 1 to 3 of 3
  1. #1
    lawmans3 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    1

    Sorting ignoring first letter of data?

    I have a list of badge numbers and I would like to sort them numerically but since they have a letter in front access doesn't sort them the way I would like. Here is an example of the data:



    P1
    P215
    P75
    P5

    I've tried using the MID function like =MID([Badge#],1) but I can't get it to work. Any help would be appreciated!

    Thanks,
    mitch

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Try:

    Mid([Badge#],2)

    or

    Val(Mid([Badge#],2))

    BTW, advise no spaces or special characters/punctuation (underscore is exception) in names. Better would be BadgeNum or Badge_Num.
    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
    Rawb is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    If the Badge numbers can vary in length (some are 3 characters, some 4, etc.) then you may also need to cast the resulting value to a number. If not, it will probably sort the result as strings (so 749 will show up before 75):

    Code:
    CLng(Mid([Badge#],2))
    This will force Access to treat the numbers as Longs (Integers that support very large values) and may give you a more expected result when sorting.

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

Similar Threads

  1. ignoring null value in recordset
    By nickblitz in forum Access
    Replies: 10
    Last Post: 11-16-2012, 02:38 AM
  2. Replies: 4
    Last Post: 09-18-2012, 05:07 AM
  3. Count Query w/o ignoring Nulls
    By Dulanic in forum Queries
    Replies: 3
    Last Post: 03-21-2012, 11:56 AM
  4. VBA excluding (Ignoring) Comma
    By RedWolf3x in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 05:15 PM
  5. Filtering/sorting data
    By jemelton in forum Access
    Replies: 5
    Last Post: 06-09-2010, 01:47 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