How to auto update related fields

  • Thread starter Thread starter Kath
  • Start date Start date
K

Kath

I have a form that I use to update info. Is there a way
of setting up that will auto populate two fields when the
third one is selected from a combo box?

Thanks!
 
Put some code to populate the textboxes in the OnClick / OnChange event of
the Combo box?

ChrisM
 
I have a form that I use to update info. Is there a way
of setting up that will auto populate two fields when the
third one is selected from a combo box?

Thanks!

First, decide if you really want to do this! Are you attempting to
copy fields redundantly from one table into another? If so, you
probably should NOT be doing so.

If you just want to display them on the form, include the fields you
want to see in the combo box's RowSource, and set the ColumnCount
property of the combo to include them; then put two additional
textboxes on the form with control source

=comboboxname.Column(n)

where (n) is the *zero based* subscript of the field (i.e. if the
field you want to see is the third field in the query use (2) as the
subscript to Column).
 
Dear John:
I am not trying to reproduce the same info in another
table. I am trying to create new client list for whom we
need addresses and zipcode, stuff like that.

I have a list of cities that have correlating zipcodes (or
you can call it vise versa), it would be great if I don't
need to type in the cities (lots of clients are from the
same 20 something cities) if I can just use the zipcode as
a toggle for auto population of the cells CITY,and STATE.
We also give counties in WA state a county code that can
be done in the same fashion if I know how.
Please help. Highly appreciated! At what time are the
live chat? Where is the link?
Thanks,
Kath
 
Dear John:
I am not trying to reproduce the same info in another
table. I am trying to create new client list for whom we
need addresses and zipcode, stuff like that.

I have a list of cities that have correlating zipcodes (or
you can call it vise versa), it would be great if I don't
need to type in the cities (lots of clients are from the
same 20 something cities) if I can just use the zipcode as
a toggle for auto population of the cells CITY,and STATE.
We also give counties in WA state a county code that can
be done in the same fashion if I know how.
Please help. Highly appreciated! At what time are the
live chat? Where is the link?
Thanks,
Kath

I'd simply store the zipcode in the Address table, then. Except for
the rather uncommon cases where a given zipcode covers several cities,
you can simply create a Query joining your contacts table to this
table by Zip, and pull the city, state, and (for that matter) county
from the zipcode table.

Howver, there may be some benefit to storing the city etc. in the
address table; it'll be a bit faster than using a Query and will allow
for (e.g.) a zipcode that laps over a county boundary. Use a Form
bound to your address table, with a Combo Box displaying the zip (and
bound to the zip field in your table); include the city, state, and
county in the combo's rowsource query.

Then in the combo's AfterUpdate event put code like

Private Sub cboZip_AfterUpdate()
Me!txtCity = cboZip.Column(1)
Me!txtState = cboZip.Column(2)
Me!txtCounty = cboZip.Column(3)
End Sub

Note that the Column property is zero based - I'm assuming the first
column, Column(0), is the zip field.
 
Back
Top