Form field auto populates based on cbo1 and cbo 2 selections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like my form field to populate based on what the user selects from 2
combo boxes I have. I have a table set up with Region, Position, and Name. I
would like when the user selects for example Eastern for the region and
President for the position that John Smith would auto populate in the form
field. Is this possible and if so, how can I get this to work?
 
Todd,

There are a number of approaches that could be taken to this. Here's
one example...

Set the Row Source of the cbo1 to the equivalent of this...
SELECT DISTINCT Region FROM YourTable

Set the Row Source of the cbo2 to the equivalent of this...
SELECT Position,PersonName FROM YourTable WHERE Region=[cbo1]

Set the Control Source of a textbox to the equivalent of this...
=[cbo2].[Column](1)

Notice I changed the field name from Name to PersonName. 'Name' is a
reserveed Word (i.e. has a special meaning) in Access, and as such
should not be used as the name of a field or control.

The question of showing related data on a form is discussed in this
article...
http://accesstips.datamanagementsolutions.biz/lookup.htm
 
Steve-
One more kink in the plan. I need the form field to also store the result
Todd,

There are a number of approaches that could be taken to this. Here's
one example...

Set the Row Source of the cbo1 to the equivalent of this...
SELECT DISTINCT Region FROM YourTable

Set the Row Source of the cbo2 to the equivalent of this...
SELECT Position,PersonName FROM YourTable WHERE Region=[cbo1]

Set the Control Source of a textbox to the equivalent of this...
=[cbo2].[Column](1)

Notice I changed the field name from Name to PersonName. 'Name' is a
reserveed Word (i.e. has a special meaning) in Access, and as such
should not be used as the name of a field or control.

The question of showing related data on a form is discussed in this
article...
http://accesstips.datamanagementsolutions.biz/lookup.htm

--
Steve Schapel, Microsoft Access MVP

I would like my form field to populate based on what the user selects from 2
combo boxes I have. I have a table set up with Region, Position, and Name. I
would like when the user selects for example Eastern for the region and
President for the position that John Smith would auto populate in the form
field. Is this possible and if so, how can I get this to work?
 
Todd,

Well, you used the word kink, not me :-) Certainly, your requirement
to do so would indicate an invalid table design. Can you post back with
some more complete details of your tables and forms, so that we can
advise more explicitly?
 
Back
Top