Solved

Splitting Address in Ms Access

Posted on 2011-02-23
4
322 Views
Last Modified: 2012-05-11
I have an Address field, I want to split
for example
Any townville Az 34563
Any townville would be in 1field and Az 34563 would be in another field.
It is consistently taking off the right 8 characters, placing in another field.
0
Comment
Question by:highhill
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 34966908
Field1:trim(left([Address],Len([Address])-8))
Field2:right([address],8)
0
 

Assisted Solution

by:sshull
sshull earned 100 total points
ID: 34966914
If you are 100% sure that there won't be any data besides the two letter state & 5 digit zip code, and that both will always be present, you can create a query that will get the data
 SELECT left("fieldname", Len("fieldname) - 8)

Open in new window

What this code does is gets all the characters that are on the left hand side with a length of whatever the field is minus the 8 characters that will be on the end. The other half would be easy since you can do a
SELECT RIGHT("fieldname",8)

Open in new window

to get all the state information. You would have to build these into your insert statement to store the data in your database.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34966932
Why would you NOT split the state and ZIP code into separate columns?

And what happens if you have a record with a ZIP+4?  Just taking the righthand 8 characters will give the wrong result.
0
 

Author Closing Comment

by:highhill
ID: 34976204
In this situation I was importing address in from a spreadsheet. The zip codes were all 5 digit, there already was a field with the zip code so all I needed was to separate out the City and State.
Thanks everyone for there help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exporting from Access 2016 to a CSV file 4 49
Insert Into syntax error 10 31
Access 2016 Query with Proper Case logic 2 34
Why having to press tab key twice? 4 17
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
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 …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

828 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