Solved

Splitting Address in Ms Access

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

20 Experts available now in Live!

Get 1:1 Help Now