How to create fields in form that call up data in table when data.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to create a field, that when data is entered, the value is matched
with a value in a linked table and a value from the table, related to the
matching value, is automatically entered in another field.
 
Hi, Budjackam.

Be careful to distinguish between *fields*, which exist in tables, and
*controls* that exist on forms (and reports). A form control may be bound to
a field or unbound. If it's bound to a field, whenever data is entered into
the control, it is stored in the corresponding field as well.

If your question means you wish only to display information from the related
table, such as the phone number or address of a customer, once the customer
number is entered, for example, there are two ways to do this:

1) Base your form on a query that includes all the fields you wish to display.
2) Create a combo box for the first field, and include the other fields to
display as additional columns. You can prevent them from displaying by
setting their Column Width to 0". To assign a column to another form
control, set the Control Source to = YourComboBoxName.Column(index), where
index is the column number. The first column is 0, the second 1, etc.

Your question implied that you might also wish to *store* this data in a
field of the table on which the form is based. This is normally undesirable.
Since the tables are related by a common field, you can always produce this
other field through a query when you need it for a form or report. Storing
it is normally redundant, and changes in the first table will not be
reflected in the 2nd. There are exceptions to this, such as the current
price of a given product, in which case you would certainly want to store the
current value. If this applies to your situation, you can assign the value
via the AfterUpdate event of the combo box:

Me![fieldname]=YourComboBox.Column(index)

HTH
Sprinks
 
Back
Top