Divide one field into 2 seperate fields

  • Thread starter Thread starter James G via AccessMonster.com
  • Start date Start date
J

James G via AccessMonster.com

Hi

I have a City_State field in my db. for example Ga,Atlanta. How could i
seperate the city and state and put them in separate fields. Is there a way
to do this programmatically? Thank you!
 
Dim varAdress as Variant
varAddress = Split(City_State], ",")
City = Trim(varAddress(0))
State = Trim(varAddress(1))
 
Oops, I got the index backwards, the state will be varAddress(0) and the City
will be varAddress(1), sorry
 
Hi James,

If the State is always two characters"
State: Left(City_State,2)
City: Mid(City_State,4,50)

If the state is sometime spelled out, but comma separated:
State: Left(City_State,InStr([City_State],",")-1)
City: Mid(City_State,InStr([City_State],",")+1,50)

HTH,
MCEscher
 
Thank a lot guys for your help. It worked perfectly. This is why i keep
coming back to you guys. I've been to other forums and nobody ever answers
my questions quickly enough or answers them correctly for that matter.
 
Back
Top