Mar 17th, 2017, 06:56 AM
Best way to get list of US States
What do you recommend as the "best" way to get the data to present in a dropdownlist of states in the U.S. to a user?
It's not so big or changeable that I couldn't just hardcode it. And if so, is an XML file better than just adding it to my code?
Would a webservice be better? Or is that overkill?
We have a database table and no user interface to it yet. It contains address information. As I'm thinking about creating a grid, I don't know if I should make it easy for the user to get the state right and not make a typo entering it freeform. And should I stop there, or go on with zip codes and cities? If so, I would want a webservice. Do you know of a good one?
There are 10 kinds of people in this world. Those who understand binary, and those who don't.
Mar 17th, 2017, 07:21 AM
Re: Best way to get list of US States
Here's how we have ours setup. We have a Country table (we deal with international clients)... ID, Name, Abbreviation. Then a State table, ID, Name, Abbreviation, CountryID. Then we also have what we call a CityStateZip table. ID, City, StateID, ZipCode. For Country and State tables, we have an interface that allows the user to add/edit/remove entries. Also there's options in our file import process that allows us to indicate if missing entries should be added to the tables (otherwise it's an import error). For the CSZ table, there's the import process which will add to it (independent from the option of the other two), and two additional ways. One is by manual entry from the person screens. When someone enters an address, it looks to see if that combination exists in the table, and if it doesn't, it adds it. We also have a specialized import process that reads a USPS file and populates the data with that data.
During data entry, the Country and State fields are dropdowns with typeahead turned on. the Zip is a search field, but will allow new entries if one isn't found initially.
edit - oh, and we can also switch between displaying the name or abbreviation in both cases too. It's just either QueryFull or QueryAbbreviation.
Click Here to Expand Forum to Full Width
Survey posted by VBForums.