Auto Zip Code entry

B

Bob

Is there a defined document on how to create the fields
and properties in the table and or form to auto enter the
zip code once you choice the town from the pull down combo
box?
 
C

Cheryl Fischer

I am not aware of any such document regarding auto-filling address
information based on zip codes. Typically, you would use a multi-column
combo box to implement auto-filling data based on a selection from a list.
Your example, however, may pose problems unless your application will *only*
deal with cities which have only a single zip code. For example, in
Houston, TX, Los Angeles, CA, New York, NY, there are hundreds of zip codes
available for each city. Even a small city may have two zip codes.

The following example is for a combo box from which a user will select a zip
code and, based on that selection, city and state will be auto-filled. You
can, of course, edit it to work with your application.


1. Make the control on your form for zip code a combo box.

2. Set the properties of your combo box as follows:

Row Source: Select ZipCode, City, State from tblZipCodes Order by ZipCode
Column Count: 3
Bound Column: 1
Control Source: name of zipcode field in the table which is the
RecordSource of your form

3. In the After Update event for your combo box, insert the following code,
which will update City and State fields on your form:

Me!City = Me!MyComboBox.Column(1)
Me!State = Me!MyComboBox.Column(2)

hth,
 
J

Jeff Boyce

Bob

Nice thought, won't happen. I live in a very small community which has at
least 7 zip codes. Consider trying the other way around -- enter the zip
code, get the city.
 
B

Bob

Thanks for the info. Once this table was created it
consist of a column for the town and the second column
for the zip code. In the form the town and zip code are
separated fields. The town field is a combo box the zip
field should be what kind of field?. When selecting a town
from the combo box, with reference to what you explained.
Will the zip code auto appear in the zip code field of
that form? In the table of the two columns with the town
and zip code mentioned earlier all towns with their
respectful zip code were entered manually.
 
C

Cheryl Fischer

Thanks for the info. Once this table was created it
consist of a column for the town and the second column
for the zip code. In the form the town and zip code are
separated fields. The town field is a combo box the zip
field should be what kind of field?.

A text box.
When selecting a town
from the combo box, with reference to what you explained.
Will the zip code auto appear in the zip code field of
that form?

Yes, if you edit the code I supplied to so that the zipcode textbox is
auto-filled:

Me!ZipCode = Me!MyComboBox.Column(1)

Please note: If your table of cities and zipcodes contains ONLY cities
which have a SINGLE zip code, your logic of selecting a City and
auto-filling a zip code will work. As soon as your database requires that
you enter an address for a city which has more than one zip code, you cannot
expect that simple selection of a city entry from a combo box will provide
the correct zip code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top