From: MacNut2004 on
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
From: Dorian on
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".


"MacNut2004" wrote:

> 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
From: Daryl S on
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.

--
Daryl S


"MacNut2004" wrote:

> 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
From: MacNut2004 on
Daryl,

Thank you so much - worked like a charm. ;)

MN

"Daryl S" wrote:

> 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.
>
> --
> Daryl S
>
>
> "MacNut2004" wrote:
>
> > 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
 | 
Pages: 1
Prev: Refresh subform
Next: Prevent going to New Record