Solved

sort by last five digits in query field

Posted on 2013-01-06
2
586 Views
Last Modified: 2013-01-07
MS Access 2007: i have a table I'm querying from a exported xls file that has a nasty field with the city,state (2 digit) and the zip code all combined. I need to sort on the zip code which is the last five digits of the field but in some cases, there is no zip code in some of the records. If it helps any, all of the records use the 2 digit state of Tx followed by the five digit zip code (for example: Dallas,Tx 12345), if available. I need to do this in the query or the applicable report which I derive from this query.
0
Comment
Question by:howcheat
[X]
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
2 Comments
 
LVL 10

Accepted Solution

by:
etech0 earned 500 total points
ID: 38749646
Add another field to the query, like this:

zip: Right([FieldContainingCityStateZip],5)

In the criteria row, put this:

<"a"

That will filter it so you only see the numeric ones.

Then, sort that field. You can uncheck Show if you don't want to see it.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38749657
add another column to your query with something like this

right([NameOfField],5)


ascending


-------------------------

to handle the records with no zip code, you can do this

iif(isnumeric(right([nameofField],5)), right([nameofField],5),"99999")
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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

690 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