Populate field based on combo box

M

maryj

I know this shouldn't be so hard - but I'm having a brain ... or something!

On a form, I would like to select a District Number from a combo box and
have the District Name appear in a text field. My form is based on a query. I
know somehow I need to add criteria to my query to point to the info in the
combo box but I'm not sure exactly where to put this criteria. Should the
combo box field for the District Number on the form be based on the
Districts table or is this the field that comes from the query? Or is it the
District Name field that comes from the query? I have never done this before
and am quite confused (and frustrated!!) so please give me specific
information.

A huge thank you!!!
 
A

Arvin Meyer [MVP]

OK, take a deep breath. It's really quite simple.

In your combobox, add the second value you want to display in the textbox.
So now the Select statement for the combo will look something like:

Select [District Number], [District Name] From MyTable;

Change the column count property of the combo from 1 to 2, and change the
column width properties to what you have now and 0" so it will look
something like:

1.5";0"

Now you've fixed the combo, all we need to do is fix the controlsource of
the textbox. That should read:

=Forms![MyFormName]![MyComboName].Column(1)

Column 1 being the second column in a zero based column index. Make sure all
the names match the names for your objects. Walla! we're done.
 
M

maryj

Thanks Arvin! That worked perfectly. I knew it wasn't too hard but just had a
mind block.
--
maryj


Arvin Meyer said:
OK, take a deep breath. It's really quite simple.

In your combobox, add the second value you want to display in the textbox.
So now the Select statement for the combo will look something like:

Select [District Number], [District Name] From MyTable;

Change the column count property of the combo from 1 to 2, and change the
column width properties to what you have now and 0" so it will look
something like:

1.5";0"

Now you've fixed the combo, all we need to do is fix the controlsource of
the textbox. That should read:

=Forms![MyFormName]![MyComboName].Column(1)

Column 1 being the second column in a zero based column index. Make sure all
the names match the names for your objects. Walla! we're done.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

maryj said:
I know this shouldn't be so hard - but I'm having a brain ... or something!

On a form, I would like to select a District Number from a combo box and
have the District Name appear in a text field. My form is based on a
query. I
know somehow I need to add criteria to my query to point to the info in
the
combo box but I'm not sure exactly where to put this criteria. Should the
combo box field for the District Number on the form be based on the
Districts table or is this the field that comes from the query? Or is it
the
District Name field that comes from the query? I have never done this
before
and am quite confused (and frustrated!!) so please give me specific
information.

A huge thank you!!!
 

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