473,800 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2323

<co*********@gm ail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.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(pstrAd dr 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(pstrAd dr, ", ") - 1)
Debug.Print strZIP
strST = Mid(pstrAddr, InStrRev(pstrAd dr, ", ") - 2, 2)
Debug.Print strST
strCity = Left(pstrAddr, InStrRev(pstrAd dr, ", ") - 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.c om
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
2888
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 and state come up automatically. I have two tables: Table 1 (14 fields): Customer Name, Address, City, State, Zip,
9
2020
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, Phone) tblzips = holds ( Zip codes, City, State, County, Country) tblzips ID Zipcode City State County Country
2
1365
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. Oh well, enough griping, here's my question: I want to be able to create graphic images showing the outline of US states and place dots on them for selected cities in a selected state. Example: North Carolina selected, Raleigh and Wilmington...
1
6570
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 have a separate submit button which should validate the other fields. This page on MSDN does what I want - almost! ...
0
1710
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) View Source URL: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetailsInsertPage.src I do understand from the Master Page (GridViewMasterDetailsInsertPage_vb.aspx) the last field from Gridview1
1
2184
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: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples...
1
2367
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 object that simply outputted something like this: Developer Detroit Michigan
3
10604
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 web.config file (VS 2005, Framework 2.0), I can retrieve the values fine: <appSettings> <add key="fileInputFolder" value="C:\National City Downloads\test"/> <add key="fileTransaction" value="\Transactions\"/>
6
4819
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 city values should display in city selection field and when user select any one city value then this state of this city should be display auto in state selection field without user selection. please solve my prolem. Thank you.
0
10507
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7582
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.