Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2006

Tip: Looking for answers? Try searching our database.

split address field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bibi - 08 Aug 2006 02:35 GMT
I am working with a large database imported from excel.  The address field
may contain a street number followed by a street name followed by an
apartment number.  Some addresses have no street number, some have no
apartment number.  I need to compile a walking list from this data so I need
to extract the street name from the "address" and then list the house number
and apartment number where applicable in separate fields. The street name may
be any number of separate words.
For example: 501 West Vernal Pike North apt. 3 or South SR 45......There are
no separators between the numbers and words, just spaces.
All help will be appreciated!
Signature

TIA
Bibi

Allen Browne - 08 Aug 2006 03:21 GMT
HI Bibi

There's really no reliable way to automate this process. The best you can
hope for is to handle the most common options, and then do the others
manually.

Presumably you have a table with a field that has this combined Address, and
you want to split it into different fields. You can use an Update query to
populate the other fields.

First step is to create the query.
Drag the combined Address field into the grid.
In the Criteria row under this field, enter:
   Is Not Null

Now, to have a shot at the street number.
In a fresh column in the Field row, enter:
   Val([Address])
In the Criteria row under this, enter:
   > 0
Check that this is giving sensible output.
Change the query to an Update query (Update on Query menu.)
Repeat the Val([Address]) in the Update row under the Streetnumber field.

Other functions you will need include: Left(), Mid(), Right(), Len(),
Instr(), InstrRev(), Trim(). For example, the last word in the address is
most likely "Street" or similar, and you can parse that word with:
   Trim(Mid([Address], InstrRev([Address], " "))
Then the middle part would be:
   Trim(Mid([Address], Len(Streetnumber) + 1, Len([Address] -
Len([Streetnumber]) - Len([StreetType]))

Ultimately, it may be an exercise in frustration, since it is not always
possible to parse addresses like that. There are just too many variations,
such as:
- First Floor, Fred Myers Building, Cnr Walter and Stein Steets
- Lot 64, Swan Road
- PO Box 99
- Unit 17B, 7A Main St
- Care Of Marth Jones, 1 Bruce St
- Room 9, Ward C, Royal Albert Hospital
and that's before we start on addresses in other countries.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I am working with a large database imported from excel.  The address field
> may contain a street number followed by a street name followed by an
[quoted text clipped - 10 lines]
> no separators between the numbers and words, just spaces.
> All help will be appreciated!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.