Results 1 to 8 of 8
  1. #1
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214

    Zip Code

    I was wondering if it is possible to create a lookup field that grabs information from the internet (similar to a web query in MS excel). I have a table with client addresses and I want to be able to type in the zip code and have it automatically fill in the city and state by looking up that particular zip code from online somehow. Is this possible?

    Thanks.
    Last edited by cbrsix; 05-25-2012 at 01:04 PM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Grabbing data from a web page is possible but not easy. I have seen threads on the topic but never implemented anything. You can buy zip code datasets.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    Would you recommend one over the other as a better solution?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I think the web grab will be very difficult, if even possible. For the other option, look at this http://databases.about.com/od/access...dedatabase.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    I haven't tried working with a web page to submit a value and try to parse the returned html for a response.
    However, here is a site, and there is a box for you to enter a ZIP code,
    http://www.50states.com/zipcodes/alabama.htm
    It will return a response.
    http://www.411.com/search/ReverseZip...0744&zip=33468

    So you would have some vba to submit your zip code to that site, and some vba to get the returned html and parse through it to find the City and State.

    If you can get something working, I'm sure others would be interested.

    Good luck.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I can get you this far. I found USPS web page that when it opens cursor is in an entry box. Unfortunately, can't get it to execute the search. User has to click button on web page. Set a VBA library reference to Microsoft Internet Controls.
    Code:
    Private Sub tbxZip_AfterUpdate()
    Dim oBrowser As InternetExplorer
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    oBrowser.Navigate "https://tools.usps.com/go/ZipLookupAction!input.action"
    oBrowser.Visible = True
    Do
        'Wait till the Browser is loaded
    Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE
    SendKeys "{tab}{tab}{tab}{tab}" & Me.tbxZip & "{tab}", True
    End Sub
    Even if could force the search, no idea how to parse the data from the results page. Then there is the issue of closing the page. I don't think VBA can selectively close a web page, have to kill all instances of the browser. I also can't get code to work with any other browser.

    As I said earlier, not easy, if at all.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I just found an up to date site for Zip codes. The file can be downloaded as a .csv and then imported.

    http://federalgovernmentzipcodes.us/

    Alan

  8. #8
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    Thanks for the suggestions. I think I'm just going to import a data set with all of the needed data.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  2. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  3. Help with VBA code
    By bgonzal1 in forum Access
    Replies: 3
    Last Post: 12-14-2009, 07:12 AM
  4. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  5. Need Help Getting to Code
    By Snuffles in forum Programming
    Replies: 8
    Last Post: 04-22-2008, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums