473,414 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Separate City, State and Zip

Hi:
Can any one please tell me how do i separate city state and zip. I ask
this question in previous post. But when the city name is in two words
it mess up my values otherwise it works.

CityStateZip
-------------
Las Vegas NA, 12345
Oradell NJ, 07649
Bay Shore NY, 11703

Thanks.

Nov 11 '06 #1
2 2304

<co*********@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Hi:
Can any one please tell me how do i separate city state and zip. I ask
this question in previous post. But when the city name is in two words
it mess up my values otherwise it works.

CityStateZip
-------------
Las Vegas NA, 12345
Oradell NJ, 07649
Bay Shore NY, 11703
The following very-lightly-tested code seems to work fine on the samples you
gave (just for the record, there's no state with the abbreviation "NA").

Function SplitAdd(pstrAddr As String) As Boolean
On Error GoTo Proc_Error
Dim strZIP As String
Dim strST As String
Dim strCity As String
SplitAddr = False 'Preset for "fail" return
strZIP = Right(pstrAddr, Len(pstrAddr) - InStrRev(pstrAddr, ", ") - 1)
Debug.Print strZIP
strST = Mid(pstrAddr, InStrRev(pstrAddr, ", ") - 2, 2)
Debug.Print strST
strCity = Left(pstrAddr, InStrRev(pstrAddr, ", ") - 3)
Debug.Print strCity
SplitAddr = True 'Set for "success" return
Proc_Exit:
On Error GoTo 0
Exit Function

Proc_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
SplitAdd of Module TestModule1"
Resume Proc_Exit
End Function

You'll likely want to change it to pass the variables into which to return
the separate parts of the address, and there's no particular reason for
having it as a Function instead of a Sub procedures (it was simple to test
as a function)
Nov 11 '06 #2
colleen1980,

While I'm sure Larry's code will do the job just fine, I posted a much
simpler method on the "other" forum where you posted the the same question
under the handle "Mustish1"

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200611/1

Nov 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: CaliSchmuck | last post by:
I think this is probably simple, but I'm having a problem figuring it out. I have a form that is used to enter data. I want users to be able to enter a zip code in the form, and have the city...
9
by: Mike McGee | last post by:
I am new to database apps, but I am making a db with access 2002. Here is what I have and what I would like for it to do. tblCustomers = holds customer info (Name, Address, City, State, Zip,...
2
by: MLH | last post by:
Fat chance, huh? If its not in the public domain, it ought-a-be. As much tax money spent by the USGS & other dept's, every US citizen should be given a copy of s'ware near as powerful as MapInfo....
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
0
by: Sam | last post by:
Folks, Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetailsInsertPage_vb.aspx 2)...
1
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
1
by: Jamie J. Begin | last post by:
I'm very new to the world of Python and am trying to wrap my head around it's OOP model. Much of my OOP experience comes from VB.Net, which is very different. Let's say I wanted to create an...
3
by: Blasting Cap | last post by:
I am working on a web app that I want to be able to use a separate config file on, in addition to the web.config file that's already working in the application. If I put the following in the...
6
by: dkyadav80 | last post by:
Hi sir, I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be store in xml file. when user select city then all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.