Solved

Splitting Address in Ms Access

Posted on 2011-02-23
4
313 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 - query 23 57
Programmer 14 47
Passing variables to a function 6 34
Access check if a table is open 4 39
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

786 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