Value in Combox populates other fields in form

M

MacNut2004

Hello,

I have a form that has an unbound combobox (Company) that looks up company
names in a table. Depending on the value of Company, it will automatically
update other fields on the form: Address, Phone Number, State, etc.

How do I go about doing this?

Thanks!
MN
 
D

Dorian

In After Update event for combo box you insert the code to test for the
selected value and then set the other field values.
E.g.
Select Case Me!MyCombo
Case "Microsoft"
Me!SearchEngine = "Bing"
Case "Google"
Me!SearchEngine = "Google"
...
End select

If Company selection determines other values it is a sign that you need to
control this via a table where you would have the Company and the related
values for each other field. It's not good to code such things in your logic.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

Daryl S

MN -

Set the Row Source for the combo box to pull all the fields you need from
the company table. Something like this (but use your table and field names):
Select CompanyID, CompanyName, CompanyState, CompanyZip from Company

Even though you are pulling 4 (or more) fields from the Company Table, you
can choose to only display one of them. You do this with the Column Widths
property. This will only show the second column:
0";2.5";0";0"

Then in the On Click event for the combo box, add code like this (but use
your control names):
Me.txtState = Me.cboName.Column(2)
Me.txtZip = Me.cboName.Column(3)

Note that column(0) refers to the first column in the combobox, etc.
 

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