Solved

sort by last five digits in query field

Posted on 2013-01-06
2
575 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
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 119

Expert Comment

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now