Auto-populate fields in form based on combo box selection

G

Guest

I am creating a form that links information from an employee table to other
inputted information. I am using a form as the method of input. I would
like the users to choose an employee id from a combo box and then have the
form auto-populate several other fields (i.e. First name, Last Name, Job
Title, Date of Birth) in the form as well as in the table being
created...whether its via combo boxes with choices limited to the results of
the ID or through auto-populating. Any help would be greatly appreciated!!
 
R

Rick B

Populating controls on the form would make sense so the user could see who
they were dealing with. Populating the data in bound fields on the form
that would then add the information to another table would not make sense.
That violates normalized relational database design.

You store the employee data in the employee table. Your new table (whatever
it is for) would only store the employee Number (or ID), not the data. For
example...

tblEmployee
EmployeeNumber
LastName
FirstName
Address
Department
etc.


tblSalary
EmployeeNumber
EffectiveDate
AnnualAmount


Etc.
 
B

BruceM

One way of displaying the fields on the record is to include the desired
information in the combo box row source. If, for instance, DOB is in the
third column of your combo box row source query, then you could have an
unbound combo box on the form with the control source:
=[cboYourComboBox].Column(2)
You need to make sure that the column count for the combo box is set to the
number of fields you need to display. For instance, in the example I just
gave your combo box column count needs to be 3 (the first column is numbered
0) in order for you to display DOB. Set the width to 0 for any columns you
do not want to see in the combo box, but they still need to be counted.
Note that in some cases you may want to store the information. If
somebody's job title may change, and if a record needs to show the job title
at the time the record was created, you will need to store that information.
DOB, on the other hand, will not change.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top