Computer Learning Zone CLZ Access Excel Word Windows

Science is based on experiment, on a willingness to challenge old dogma, on an openness to see the universe as it really is. Accordingly, science sometimes requires courage - at the very least the courage to question the conventional wisdom.

-Carl Sagan
 
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
 
Home > Courses > Access > Templates > ZIP Code
 
ZIP Code Lookup Template

In this template tutorial, I'm going to show you how to perform a ZIP code lookup. You will be able to enter a ZIP code and have the system return the city and state for that ZIP code (yes, works with most foreign countries too). If it doesn't exist in the database, you will be prompted to add it.


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Buy Now

Lessons

Database Files

Free Version

Want to learn more about this template and how it's built? The first video above is the FREE TechHelp version of the template and shows how to work with a single city/state for a ZIP code. Click on the download link to get a copy of the FREE template created in the video.

Extended Version

In the Extended Version of this tutorial, if the ZIP code exists but there is only ONE city in the database for that ZIP code, it will return it and populate your customer form. If the ZIP code exists but there are multiple cities, a form will appear allowing the user to select which city to use.

ZIP Code Lookup Template Microsoft Access
 

You can purchase your copy of this tutorial by clicking on the button below. You get the full 27 minute extended video tutorial plus an editable template:

Order Now

Customize For Your Needs

If you would like to discuss customizing this database for your needs, please see my consulting page for details on rates and other information.

 

Use ZIPLookupF from other forms Upload Images   Link  
Ray White 
2 years ago
Hi Richard
Question:
On the ZIPLookupF you have the code
    Forms!CustomerF!City = City
    Forms!CustomerF!State = State
    Forms!CustomerF!Country = Country
    DoCmd.Close acForm, "ZIPLookupF", acSaveYes
*******************************
This will only work for this one form CustomerF

Question is:
How could you use this same ZIPLookupF
form for other forms without of having to make a new ZIPLookupF for any other form that you may need to use it with.
in the Forms!CustomerF it needs to be which ever form you opened it with.

Richard Rost
2 years ago
Yeah, that's a limitation of how I built it. A trick I've used to make a form flexible so it can be called from any number of different forms is to store the name of the CALLING form (the form that opened it) in a hidden field on ZipLookupF. So you might have:

Docmd.OpenForm "ZipLookupF"
Forms!ZipLookupF!HiddenCallingFormName = "ClientF"

Now in the ZipLookupF instead of "hard coding" CustomerF, you could say:

Forms(HiddenCallingFormName)!City = City
Forms(HiddenCallingFormName)!State = State

I use this trick in my Calendar Seminar and Templates so that ANY form can call the Calendar popup.

Good question!
Richard Rost
2 years ago
Or to make THAT code even MORE flexible, you could say:

Docmd.OpenForm "ZipLookupF"
Forms!ZipLookupF!HiddenCallingFormName = Me.Name

And now you can just drop that code into ANY form without having to edit the form name.
Richard Rost
2 years ago
Basically, there are multiple ways to reference an open form in Access. I've generally taught:

Forms!CustomerF!FirstName

But this is also acceptable, and allows for programmability:

Forms("CustomerF")!FirstName
Ray White
2 years ago
Thanks Richard
I'll try that out.
Richard Rost
2 years ago
My pleasure.
Ray White
2 years ago
That works GREAT.. Thanks Richard
So now I can use my frmZipCodeSelector from any other form.
Just put the HiddenCallingFormName text box on the frmZipCodeSelector and have it hidden.

*********************************************************************
Then in the cmdSet button on the frmZipCodeSelector form:

Private Sub cmdSetZip_Click()
    Forms(HiddenCallingFormName)!City = City
    Forms(HiddenCallingFormName)!State = State
    DoCmd.Close acForm, "frmZipCodeSelector", acSaveYes
End Sub
*************************************************************

This will be in the form that calls the frmZipCodeSelector

Private Sub OpenZIPForm()
    DoCmd.OpenForm "frmZipCodeSelector", , , "ZipCode=""" & ZipCode
Richard Rost
2 years ago
You got it.
Add a Reply

Show All Comments

Start a NEW Conversation
 
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: access templates zip code lookup  PermaLink