Solved

Splitting Address in Ms Access

Posted on 2011-02-23
4
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

726 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