Solved

sort by last five digits in query field

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

809 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