Automatic Fill of Fields

  • Thread starter Thread starter J
  • Start date Start date
J

J

Is there a way to automatically fill fields that are
associated with an item theat I choose in another field?
For example, if I choose from a combo box a name of a
person from table A, what would I need to do to fill other
information associated with the name of the person,
pulling from the same table?

Thanks!!!

John
 
Look into the "Column()" property of your combo box. If the source of your
combo box includes the fields (even if not shown in the drop down) that
contain the associated data, you can add code to the combo box's AfterUpdate
event, something like (actual syntax may vary):

Me!txtYourFirstOtherField = Me!cboYourComboBox.Column(2)
Me!txtYourSecondOtherField = Me!cboYourComboBox.Column(3)
...
Me!txtYourXXXOtherField = Me!cboYourComboBox.Column(n)

Caution: The Column() property is zero-based, so the third column in your
underlying source is referred to as "Column(2)".

Good luck

Jeff Boyce
<Access MVP>
 
Do you really want to copy the values (so that the values are stored in two
tables) or do you just want to display the related values? To display the
related values (which in most situations is the best way since we usually
don't want to have the same information in two tables) you can do this very
easily.

First make sure that these related fields are included in the rowsource of
the combo and make sure that you increase the Column Count property to
include any new fields. Adjust the ColumnWidths property according to
whether you want to see the values when the combo is dropped down. Then for
each related field you want to display create a textbox. In the
ControlSource of the new textbox put

=me.MyCombo.column(3)

Then because the column property is indexed starting with 0, replace 3 with
the column number minus 1 of the field you want to display. IOW, the above
will cause the value from the 4th column to be displayed in the textbox.
 
Back
Top