Best way to get list of US States-VBForums
Results 1 to 2 of 2

Thread: Best way to get list of US States

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Rammstein concert maybe - depends on setlist.
    Posts
    3,824

    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.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    30,594

    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.

    -tg

    edit - oh, and we can also switch between displaying the name or abbreviation in both cases too. It's just either QueryFull or QueryAbbreviation.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.