Hi All,
Thanks to Tarnish and Allen Browne we have a new City, State, Zip splitter that does a better job for our needs than Right Fielder and does not require exporting data to DBFs. It is a little slower running but that time is more than made up in other ways.
When data is returned from the code Tarnish supplied, all punctuation is replaced with spaces, multiple spaces are deleted, and it is parsed into an array with each word separated. I added another array and stored the length of each component and evaluated from the right:
Last piece length 2:Copy to state and concatenate the remainder to city.
Last pair 2 and 5 numbers: 2 to state, 5 to zip, and remainder to city.
Last 3 components 2, 5 nos, 4 nos: same with zip4.
Last pair 2 and 9 numbers: 2 to state, 5 to zip, 4 to zip4, and remainder to city.
I had a test to check the 2 letter state abbreviations in a lookup table but it took too long. We may get some country codes mixed in but if it is a problem they can be cleaned up later with a query. I do have more refining and testing to do but it is quick and accurate. I also modified the code Tarnish supplied to be a bit less general and faster but the code works great.
I am always a bit nervous about not taking Skips excellent advice but this seems to clean up the mess automatically and better than Right Fielder did.
Thanks again to all that offered their input,
alr
_____________________________________
There is no rule more invariable than that we are paid for our suspicions by finding out what we expected.
Henry David Thoreau