Populate combo field on form

M

Mhebor

How would I populate a combo box field on a form based on what is
entered into another combo box. I have a table for different state
agencies and another for contact person. If a person chooses an agency
in the first combo field, I want the other combo box populated by
contacts for that agency only. Thank You in advance.
 
J

jl5000

The second combo box row source should be a query limited by the first combo
box,
Also the first combo box should have an after update event, requerying the
2nd combo box,
 
D

Damon Heron

Set the first combobox's RowSource to the table and
RowSourceType to FieldList. Add code to its AfterUpdate
event to construct the query to use in the second box's
RowSource. Like this:
combo1_afterupdate
dim strSQL as string

strSQL = "Select Distinct " & combo1 & " From table Order By " & combo1

Combo2.RowSource = strSQL
end sub
Damon
 
M

Marshall Barton

How would I populate a combo box field on a form based on what is
entered into another combo box. I have a table for different state
agencies and another for contact person. If a person chooses an agency
in the first combo field, I want the other combo box populated by
contacts for that agency only. Thank You in advance.


Take a look at this article:
http://www.mvps.org/access/forms/frm0028.htm
 
M

Mhebor


These suggestions worked, but I'm not getting the results I am looking
for. Instead of the Field name being selected in the first combo box,
I would like the value of the first combo box to determine what can be
chosen in the second combo box. On another note, how do you requery
the 2nd combo box in the after_update event in the 1st combo box.
Thanks for the quick reponse.
 
M

Marshall Barton

These suggestions worked, but I'm not getting the results I am looking
for. Instead of the Field name being selected in the first combo box,
I would like the value of the first combo box to determine what can be
chosen in the second combo box. On another note, how do you requery
the 2nd combo box in the after_update event in the 1st combo box.


You are doing something wrong. Perhaps the value of the
first combo's BoundColumn is not what you need? It's
impossible for me to provide a detailed explanation without
knowing exactly what the RowSource and BoundColumn
properties of the two combo boxes and the fields that relate
the two.

The first combo box's AfterUpdate event procedure should be
like:
Me.secondcombo = Null
Me.secondcombo.Requery
 

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