Selecting from a list to populate several fields

C

Cloudbuster

I want to make a form where I select from a dropdown in one field, and other
fields will populate with information from the record that I select. So, if
field 1 has me do a pulldown of names from a table, and I select a name, I
want the other fields to show me corresponding info from other cells in the
same table.

How do I do this?

Cloudbuster
 
A

Albert D. Kallal

On your existing form, use the wizard to build a combo box. One option is to
search via combo.

If you build the above, then selection a name from the combo box will
"display" that record, and all of its fields on the form's controls.


Give the above a try...
 
K

Ken Sheridan

Firstly, don't store the other values from the referenced table in fields in
the referencing table. This introduces redundancy and the possibility of
inconsistent data. Store only the primary key value from the referenced
table as a foreign key field in the referencing table. Lets say you want to
record which employee undertakes a sale in an Orders table, but on the Orders
form want to show the employee's first and last names and their job title,
which are fields in an Employees table. In the Orders table you'd have a
numeric EmployeeID field for this (don't use names as keys; they can be
duplicated - I once worked with two Maggie Taylors in the same office). Add
a combo box, cboEmployee say, to the Orders form with its properties as
follows:

ControlSource: EmployeeID

RowSource: SELECT EmployeeID, FirstName, LastName, JobTitle FROM
Employees ORDER BY LastName, FirstName;

BoundColum: 1
ColumnCount: 4
ColumnWidths 0cm;3cm;3cm;4cm

ListWidth: 10cm (i.e. the sum of the column widths)

If your units of measurement are imperial rather than metric Access will
automatically convert them to inches if entered in metric units The
important thing is that the first dimension of the ColumnWidths property is
zero to hide the first column. You'd need to experiment with the other
dimensions to get the best fit in the drop down list.

When you select an employee from the list the combo box will show the first
name. To show the last name and job title add two unbound text boxes to the
form, and as their ControlSource properties reference the Column property of
the combo box:

=cboEmployee.Column(2)

and

=cboEmployee.Column(3)

Note that the Column property is zero based, so Column(2) is the third
column (LastName) and Column(3) the fourth column (JobTitle). The user never
sees the EmployeeID of course as its function is purely to provide an
arbitrary unique identifier behind the scenes.

BTW tables don't have 'cells'. That's a spreadsheet concept. Tables have
rows and columns (aka records and fields).

Ken Sheridan
Stafford, England
 
H

hehe

²»ÖªµÀ´ó¼ÒÊDz»ÊÇÔÚÖйú£¬ÎªÊ²Ã´´ó¼Ò¶¼ÓÃÓ¢ÎÄдÄØ¡£¿´¶®µÄÇë»Ø¸´
 

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