Solved

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

Posted on 2014-09-23
5
199 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 119

Accepted Solution

by:
Rey Obrero 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
setting a unbound subform to a recordource in a adodb array 12 26
Combobox issue 4 25
How calculate median 5 38
Max per month 3 14
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now