Solved

Splitting Address in Ms Access

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

Accepted Solution

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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