Auto Populate other fields when on field is updated.Help!

  • Thread starter Thread starter Ann
  • Start date Start date
A

Ann

I need help. Have created a form. I am adding new records
(Students) to a table. On my form I am pulling data from
another table. Lets say that the table has the information
about the courses, Course #, Name, & Hours. I enter the
course #, and I want to auto populate two other fields on
my form with the course name and hours. How can I do
this. Would I use a query or combo or list box.
 
Hi, Ann. You can use either method.

First, though, be careful to differentiate between a FIELD
and a form CONTROL. A field is where data is stored in a
table. A control merely displays data based on its
Control Source, which might be a field, a calculation,
function call, constant, etc. In your case, once you've
entered the course number, you want to auto-populate your
form controls with the Name and Hours values that are
already stored in fields in the corresponding record of
your Courses table.

Two options:

- Base your form on a query that links your table to the
Course master table by its key field, presumably Course
#. Include the Name and Hours fields in the query, and
place them on your form. Once the Course # is entered the
other data will display.

- Use a multi-column combo box (named, say, cboCourseNum),
and reference the appropriate column in the Control Source
of the txtName and txtHours controls. The first column is
0, then 1,2, etc.

ControlName Control Source
txtName =Me!cboCourseNum.Column(1)
txtHours =Me!cboCourseNum.Column(2)

Assuming you also will be entering multiple courses for
each student, this form would likely be inserted as a
subform onto a main form based on a Registrants table,
linked by its primary key.

HTH
Kevin Sprinkel
 
Back
Top