Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ms Access Many To Many Relationship Explantion Help Please 5 41
Run Time Error 3075 15 44
Access Excel export not behaving 2 25
Export Query data to excel file 14 35
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.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 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

20 Experts available now in Live!

Get 1:1 Help Now