Combo boxes and auto-fill?

S

Sabeth

I'm making a database which happens to include a combo
box (derived from a query) of company names. My
supervisor wants me to make it so that when a company
name is selected in the combo box, that particular
company's address, city, state, zip, phone, etc are auto-
filled in. Is this even possible? Does it requier coding
(I'm virually code-illiterate)? Please help! ^^;;
 
J

John Vinson

I'm making a database which happens to include a combo
box (derived from a query) of company names. My
supervisor wants me to make it so that when a company
name is selected in the combo box, that particular
company's address, city, state, zip, phone, etc are auto-
filled in. Is this even possible? Does it requier coding
(I'm virually code-illiterate)? Please help! ^^;;

Where do you want them filled? If you're copying this information from
the Company table into another table - DON'T! Storing it redundantly
not only wastes space, but causes hassles if the company changes
address or phone.

Store ONLY the unique CompanyID in the second table. If you're not
using a Form to edit the data... well, *use a Form*. On that Form you
can put textboxes with Control Sources like

=cboCompany.Column(n)

where cboCompany is the name of the company Combo Box, and (n) is the
*zero based* subscript of the desired field in the combo's query. Just
include all the fields that you want to see on the form in the
Rowsource query, and (e.g.) if the sixth field is the phone number,
use (5) as the column number.
 
K

Kevin Sprinkel

Create a form based on the Company table with all the
fields your boss would like, plus the key field. In Form
Design view, change the Visible property of the key field
to "No". Save the form, and open up your main form in
Design view. Now drag the newly created form from the
database window and drop it into your main form; it is now
a "subform" of the "master" form. You should be prompted
to update the "Link Master Field" and "Link Child Field"
properties. Set these to the name of the field in the
underlying table of the master form and subform,
respectively.

Save the table. Now when you've entered the Company ID
code in the main table, all the other fields will
display. They will NOT, however, be stored redundantly.
You are using Access' power to bring data together from
different tables based on a foreign key field.

HTH
Kevin Sprinkel
Becker & Frondorf
 

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