Help!! Extracting data from a single field

D

Duyen

I have one field that contains City and State; but I really want two fields
(one for City and one for State)

For Example:
filed 1
Kansas City MO
Kansas City, KS

How can I extract these out into two columns
field 1 field 2
Kansas CIty MO
Kansas City KS


Please help!!!!
 
J

Jerry Whittle

Your example doesn't show a comma between the city and state in both records.
Is this correct? If there was a comma on every records, I have some code that
will do it.

On the other hand, it does show a 2-letter state. Is this true of every
record? If so you could use the Right function to extract the state.

State: Right([Field Name], 2)

Something like the below would extract the city; however it would leave
commas. You could use the Replace function to clean them up afterwards in a
secod query.

City: Left([Field Name], Len([Field Name]) -3)
 
D

Duyen

Thank you so much Jerry, that works out very well.
YOu have save me. Thanks again

Jerry Whittle said:
Your example doesn't show a comma between the city and state in both records.
Is this correct? If there was a comma on every records, I have some code that
will do it.

On the other hand, it does show a 2-letter state. Is this true of every
record? If so you could use the Right function to extract the state.

State: Right([Field Name], 2)

Something like the below would extract the city; however it would leave
commas. You could use the Replace function to clean them up afterwards in a
secod query.

City: Left([Field Name], Len([Field Name]) -3)
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Duyen said:
I have one field that contains City and State; but I really want two fields
(one for City and one for State)

For Example:
filed 1
Kansas City MO
Kansas City, KS

How can I extract these out into two columns
field 1 field 2
Kansas CIty MO
Kansas City KS


Please help!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top