A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Value in Combox populates other fields in form



 
 
Thread Tools Display Modes
  #1  
Old March 24th, 2010, 03:39 PM posted to microsoft.public.access.forms
MacNut2004
external usenet poster
 
Posts: 73
Default Value in Combox populates other fields in form

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
  #2  
Old March 24th, 2010, 04:44 PM posted to microsoft.public.access.forms
Dorian
external usenet poster
 
Posts: 542
Default Value in Combox populates other fields in form

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

  #3  
Old March 24th, 2010, 05:31 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Value in Combox populates other fields in form

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

  #4  
Old March 26th, 2010, 04:52 PM posted to microsoft.public.access.forms
MacNut2004
external usenet poster
 
Posts: 73
Default Value in Combox populates other fields in form

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.