Update a field based on another value entered on a form

I have a form where the user enters a customer's name and address.... all that goes into one table: tPatient

I also have another table (tZip) that contains two fields, zip and city.

I would like to set the main form so when the user enters the zip the City will automatcially update correctly on the form based on the users entered zip code for a particular customer.

How can this be done via VBA?

Thank you.
Who is Participating?
On the patient form, use a combo box for the zip code and a text box for the city.  Set the properties as follows:
   rowsource: "Select Zip, city from tZip"
   bound column = 0
   column count = 2

In the after update event of the combo box:
  me.CityTextboxName = me.ZipComboFieldName.column(1)

If you want to get fancy, you could make the city a combo box, as well and work it the other way.  Then, the user can choose the city/zip from either combo.

thandelAuthor Commented:
Thanks, when you say set the properities is that for the combo box and just leave the text box alone?

I tires this but after update the zip code the city text box remains null.
thandelAuthor Commented:
Ah sorry got it working had the rowselect incorect.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

thandelAuthor Commented:
Thanks!  Can't really go the other way as some cityies have more than one zip code.
I believe my solution had a typo:  bound column should = 1, not 0

>Can't really go the other way as some cityies have more than one zip code.

Not a problem...show both the city and the zip in the dropdown.  User can pick from among them:

RowSource:  Select city, zip from yourtable
Column Count = 2
Bound Column = 1

thandelAuthor Commented:
Thanks I've started another thread as new issues came up. 26988400  (Which looks like you jumped on too)  :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.