List box populated by dropdown selection

G

Guest

Hey you all.

Here is the problem. I have drop down menu where I choose a employee role.
According to this role I would like to populate a list box. List box will get
the values from table where every record has role saved. So when I choose
"user" as a role from drop down menu, I want all the records which has "user"
as role to be shown in list box.

How can I do this?
 
A

Al Campagna

Sam,
Given example combo cboRole and example listbox lstRoleRecordsThatMatch.
In the query for the RowSource in lstRoleRecordsThatMatch use a criteria like this,
against the Role field...
=Forms!YourFormName!cboRole
Always Requery the lstRoleRecordsThatMatch on the AfterUpdate event of cboRole, so that
they always stay in synch, whenever you change cboRole.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
A

Al Campagna

Sam,
If needed... on my website below, I have a sample file (A97 and A2003) called Synched
Combos which demonstrates the same principle with 2 combos.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
G

Guest

Hey thanks for the help. The example really makes sence. Still I cannot make
mine to work. Mine is slithly different. I'm using two tables, but I cannot
think of that making any difference. Here are the queries I'm using.

Combo box(name=role): SELECT roles.ID, roles.role FROM roles; //'role' is
visible

List box: SELECT projects.ID, projects.project_name FROM projects WHERE
projects.task_area=Forms!update_status_1!role;

Also behind combo box I have code on AfterUpdate event

Private Sub role_AfterUpdate()
[Forms]![update_status_1]![List11] = Null
[Forms]![update_status_1]![List11].Requery

End Sub
 
G

Guest

Hey, I figured it out. Works great now! Thank you for help Al.
--
-Sam


Sam said:
Hey thanks for the help. The example really makes sence. Still I cannot make
mine to work. Mine is slithly different. I'm using two tables, but I cannot
think of that making any difference. Here are the queries I'm using.

Combo box(name=role): SELECT roles.ID, roles.role FROM roles; //'role' is
visible

List box: SELECT projects.ID, projects.project_name FROM projects WHERE
projects.task_area=Forms!update_status_1!role;

Also behind combo box I have code on AfterUpdate event

Private Sub role_AfterUpdate()
[Forms]![update_status_1]![List11] = Null
[Forms]![update_status_1]![List11].Requery

End Sub

--
-Sam


Al Campagna said:
Sam,
If needed... on my website below, I have a sample file (A97 and A2003) called Synched
Combos which demonstrates the same principle with 2 combos.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
A

Al Campagna

Sam,
Good deal... but Nulling the Combo2 before the Requery is not necessary... unless your
Nulling out Combo1.
No big deal... gald you got it going.

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

Sam said:
Hey, I figured it out. Works great now! Thank you for help Al.
--
-Sam


Sam said:
Hey thanks for the help. The example really makes sence. Still I cannot make
mine to work. Mine is slithly different. I'm using two tables, but I cannot
think of that making any difference. Here are the queries I'm using.

Combo box(name=role): SELECT roles.ID, roles.role FROM roles; //'role' is
visible

List box: SELECT projects.ID, projects.project_name FROM projects WHERE
projects.task_area=Forms!update_status_1!role;

Also behind combo box I have code on AfterUpdate event

Private Sub role_AfterUpdate()
[Forms]![update_status_1]![List11] = Null
[Forms]![update_status_1]![List11].Requery

End Sub

--
-Sam


Al Campagna said:
Sam,
If needed... on my website below, I have a sample file (A97 and A2003) called
Synched
Combos which demonstrates the same principle with 2 combos.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

Hey you all.

Here is the problem. I have drop down menu where I choose a employee role.
According to this role I would like to populate a list box. List box will get
the values from table where every record has role saved. So when I choose
"user" as a role from drop down menu, I want all the records which has "user"
as role to be shown in list box.

How can I do this?
 

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