Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to sort an Access column with numbers that begin with a letter...?

Posted on 2014-09-23
5
207 Views
Last Modified: 2014-09-25
I have a column in Access where all the records begin with the letter O followed by numbers. How do I sort this column and keep the numbers in order?
0
Comment
Question by:Kevin Smith
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40339612
just create a query with Order By

select * from tableName
Order by [nameof the column/field]
0
 
LVL 13

Expert Comment

by:Russell Fox
ID: 40339618
You might need to chop off the "O" and cast the numbers into an INT. Are the numbers of varying lengths, like:
O123
O1234
Or all the same, like
O123456
O123457
O123458

If they're all the same length, then you should just be able to sort the column as-is, but if they vary you'll need to remove the O:
CInt(Right([YourColumn], LEN([YourColumn])-1)
0
 

Expert Comment

by:karunamoorthy p
ID: 40339697
Attach access file or give sample records to proceed further
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40339760
I agree with Russell, something along the lines of:

ORDER BY Val(Mid([yourColumn], 2))
0
 

Author Closing Comment

by:Kevin Smith
ID: 40344164
At first I thought: "duh, I know how to sort...gimme some credit." Ha. But my syntax and order was a little wonky so it wasn't sorting. I assumed it wasn't sorting 'cause of the O...turns out it was as simple as that.  Thanks to everyone!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question