Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Numerical Order
Gregory G Davis 
   
7 days ago
There is probably a simple solution to this problem which I can not find. I have a list of items ie. C-01 to C-99 but when I enter C-100 it gets put in after C-10. Because of the lettering I'm using the short text data type. Tried to adjust using format and input mask but couldn't get it to sort properly.
Donald Blackwell  @Reply  
       
7 days ago
If the # was first, you could use the techniques in Natural Sorting.

However, since that is not the case, I would probably create a calculated field in a query and sort on that:

SortField:  Right(SortString, Len(SortString) - InStr(SortString,"-"))


As Long as your data is always formatted with some character(s) before a single dash, then the # this would work. If you wanted sorted by the letter then the #:

SortField1:  Left(SortString, InStr(SortString,"-")-1)
SortField2:  Right(SortString, Len(SortString) - InStr(SortString,"-"))
John Davy  @Reply  
         
7 days ago
Hi Gregory, Have you thought about  creating 2 fields for the data. One for the character string and the second for the numeric field. I don't know if you have this possibility, for you may be working with an established system that you cannot change.   John
A Glenn Yesner  @Reply  
     
6 days ago
With a similar situation I give everything a five character identifier. Rather than C-01 use C-001. If you think the need may arise for another character make it C-0001 then when you get up to the higher numbers, C-0101 or C-1200, they all just fall in order. If you think there may come a need for two alpha characters in front start with all getting two characters then go AA-, AB- then eventually CA-, CB-. The end result AB-1205, BA-0001, etc. all identifiers get the same number of characters.
Gregory G Davis OP  @Reply  
   
4 days ago
Thanks for your suggestions folks. Using Donald Blackwells' suggest produced the same results, C-100 showed up right after C-10 and I'm afraid John Davy's suggestion would probably work but not feasible in this case. So the only solution that worked was to pad the numbers with zeros which I wanted to stay away from. Even tried to get some help from AI but so far that suggestion only produced 0's. Thanks again for your suggestions - much appreciated.    GD
Donald Blackwell  @Reply  
       
4 days ago
Gregory G
In my suggestion for field 2, you could add clng( before the right function and then add an extra ) at the end.
Add a Reply Upload an Image
Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/9/2026 7:09:30 PM. PLT: 1s