Sorting in Access 2013/SQL 2012

I've been given a database to modify.  It's an Access front with a SQL back-end.  
They want to sort by the case number with the newest one listed first; no big deal, except that the case number is the two digit year followed by another number..."15-017" (basically, the 17th case in 2015).  Basically I need to sort by the first number, then the second number.  It's stored as one record (nvarchar10) in SQL.  Unfortunately, there is data from the late 1900s so there are some cases that start with 99-, 98-, 97-, etc.
The sorting only needs to be done on one form so I would like to do this within the Access front end and not have to change anything in SQL.
I'm not overly experienced in Access so would like to keep the resolution as simple as possible.

Any ideas?

Thanks,
~Rick
dcgimoAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Unless you have another Date field you can use, you'll probably need to split up that concated value into the "atomic" parts. If the format is always "99-000", then you could use this in an Access query:

SELECT LEFT(YourField, 2) AS SeqYear, RIGHT(YourField, 3) AS SeqNum, OtherCol1, OtherCol2, OtherCol3, etc FROM YourTable

From there you could "sort" by SeqYear and SeqNum. You might find you need to add the full year:

SELECT IIF(Left(YOurField, 2) > 80, '19' + Left(YourField, 2), '20' + Left(YourField,2) AS SeqYear, etc etc
0
 
dcgimoAuthor Commented:
Is there a way to split it in the front-end without modifying the table in SQL?

Thanks,
~Rick
0
 
Jeffrey CoachmanMIS LiasonCommented:
No Points wanted...

What Scott posted would be done in a query, (in the front end)...then that query would be used instead of a "table"
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
As Jeff indicates, you can do this in the FrontEnd with a Query, or you can add a View to the backend (no table mods needed) and perform the split there. If you use a View, you'll have to "link" the view to your FE, of course. In most cases, unless there are some heavy duty lifting to be done, you're better off doing this in Access.
0
 
dcgimoAuthor Commented:
Working with a coworker on this that is more proficient in Access/SQL, she was able to get what we need with a view and your statements above, Scott.  All we need now is to figure a way to enter data via the view.  

Thanks,
~Rick
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Generally speaking, if the tables on which your View is based allow for mods/adds/deletes, then you should be able to edit data through the view.

This MSDN article may shed some light:

https://msdn.microsoft.com/en-us/library/ms180800.aspx
0
 
dcgimoAuthor Commented:
Thanks for the assistance.  It's working great now!
~Rick
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.