Updating form from a combo Box

D

Denise Pollock

I have a form with company name and address, numbers, contact information etc.

I want to be able to select the company in the combo box and have all the
other fields populate. Also I would like the other fields to not be
updatable in this form. What code do I need to make the form update? And
only the one combo box available to be changed.
 
F

fredg

I have a form with company name and address, numbers, contact information etc.

I want to be able to select the company in the combo box and have all the
other fields populate. Also I would like the other fields to not be
updatable in this form. What code do I need to make the form update? And
only the one combo box available to be changed.

Easiest method is to include all of the pertinent fields in the combo
box rowsource query.
You can hide them by setting the column widths property of the combo
box to 0" for those columns.

Using unbound controls, set the control source of one to:
=ComboName.Column(1)
Set the control source of another unbound control to:
=ComboName.Column(2)
etc.

Note... A Combo box's columns are Zero based, so Column(1) is the 2nd
column. Adjust the column numbers accordingly
 
D

Denise Pollock

Thank you. That works great. But now I have another problem.
I have a main form with project information, and a contractor subform(The
one I just modified). I want to be able to select the contractor on the
subform and have it populate a field in a table which is the control source
for the main form. So that everytime I look up that project the same
contractor is showing, unless I click it and change it. Each company has an
entity ID which I want to populate in the table for the project to tie them
together. I tried to set the row source to that field in the table but now I
cannot select a company from the combo box on the form. How can I fix this?
 
D

Denise Pollock

The DBA is a big fan of subforms so it was his suggestion. I changed it to
pull data from a query and that was much simpler and it worked.

Thanks!

Marshall Barton said:
Denise said:
Thank you. That works great. But now I have another problem.
I have a main form with project information, and a contractor subform(The
one I just modified). I want to be able to select the contractor on the
subform and have it populate a field in a table which is the control source
for the main form. So that everytime I look up that project the same
contractor is showing, unless I click it and change it. Each company has an
entity ID which I want to populate in the table for the project to tie them
together. I tried to set the row source to that field in the table but now I
cannot select a company from the combo box on the form. How can I fix this?


Something smells fishy with that arrangement. If the
contractor is related to the main form's table, then why are
you selecting it in the subform? If it's really related to
the subform's table, then it should not be in the main
form's table. Remember that you can always use a query to
join the two tables to get the virtual result without
munging the main table.

If you must do that, then I think you can do it by using a
line of code in the subform combo box's AfterUpdate event:
Parent.[contractor text box] = Me.[subform combo box]
 

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