Filter dropdown list according to radio button value

G

Guest

I have a form whose controls gathers values from various sources (some table
data, some user-entered data) and then writes the provided values to a table
record.

There is a list control on the form that is currently populated by a lookup
table. Is there any way I can filter this list of values according to the
value of a radio button set on the same form. In other words, if the user
selects Teacher as the radio button value for the withdrawal initiate, the
withdraw reason list control would include items 1, 4, and 5 from the lookup
table. If the user selected the Student button in the radio control set, the
reson list would include all the lookup table values.

I hope this makes sense!

Thank you in advance for any advice.
 
M

Marshall Barton

B. Meincke said:
I have a form whose controls gathers values from various sources (some table
data, some user-entered data) and then writes the provided values to a table
record.

There is a list control on the form that is currently populated by a lookup
table. Is there any way I can filter this list of values according to the
value of a radio button set on the same form. In other words, if the user
selects Teacher as the radio button value for the withdrawal initiate, the
withdraw reason list control would include items 1, 4, and 5 from the lookup
table. If the user selected the Student button in the radio control set, the
reson list would include all the lookup table values.


Here's a common way to do that:
http://www.mvps.org/access/forms/frm0028.htm
 
G

Guest

Marshall,
Thank you for your reply.

This is fine except for the issue of an option that requires all the records
from the lookup table.
 
M

Marshall Barton

B. Meincke said:
This is fine except for the issue of an option that requires all the records
from the lookup table.


Change the criteria you are using to check for the All
option. If none of the options are selected, the option
group will have its default value, which should be Null. In
this case, the WHERE caluse could be along these lines:

WHERE ( . . . ) OR Form!theform.theoptiongroup Is Null

I'd be happy to be more specific, but I have no idea how
your arrangement hangs together.
 
G

Guest

Thanks for your patience, Marshall. I'm sorry I'm not expressing myself very
well.

There will never be an instance of none of the radio buttons being selected.
They represent a choice of who initiated a student's withdrawal from our
program. The choice with all ways be either Teacher or Student. If the
initiate is a teacher, there will only be a limitted number of reasons for
the withdrawal listed in the Reason combo box. But when the withdrawal is
initiated by a student, the Student option button is selected. It is this
option that needs to result in the Reason list being populated by all records
in the underlying Reason lookup table list.

Hope this clarifies things.

Again,
Thanks.
 
M

Marshall Barton

B. Meincke said:
Thanks for your patience, Marshall. I'm sorry I'm not expressing myself very
well.

There will never be an instance of none of the radio buttons being selected.
They represent a choice of who initiated a student's withdrawal from our
program. The choice with all ways be either Teacher or Student. If the
initiate is a teacher, there will only be a limitted number of reasons for
the withdrawal listed in the Reason combo box. But when the withdrawal is
initiated by a student, the Student option button is selected. It is this
option that needs to result in the Reason list being populated by all records
in the underlying Reason lookup table list.


I'm still not sure what you mean here, but maybe you can use
the same concept:

WHERE ( . . . ) OR Form!theform.theoptiongroup = X

where X is the option value for student.
 
G

Guest

If you will indulge me one last effor to explain:

I have a lookup table that populates a combo box on an unbound form. I would
like the contents of the combo box to be "filtered" according to users'
selection on a radio button group.

The radio button group consists of two buttons
Teacher, and
Student.

If the user chooses Teacher, I would like the combo box list to be limitted
to only certain records from the lookup table. However, if the user chooses
the Student radio button, I would like the combo box list to include all
records from the lookup table.

I understand how to code it to include, (for example, 1, 4 & 5,) for one
option and the remainder, (2, 3, & 6,) for the other option button, but I
can't seem to see how to code it so the combo box includes only some records
for one option but all for the other.

If it would help, the controls are named as follows:
cboReason (the combo box)
ForWhatInitiate (the radio button group)

The following are the records in the tblWDReasonLOOKUP table:
1 Unknown
2 Personal
3 Course Completed
4 Course Inappropriate
5 Course Too Difficult
6 Moved Away
7 Poor Attendance

Again, thank you for your continued support.
 
M

Marshall Barton

B. Meincke said:
If you will indulge me one last effor to explain:

I have a lookup table that populates a combo box on an unbound form. I would
like the contents of the combo box to be "filtered" according to users'
selection on a radio button group.

The radio button group consists of two buttons
Teacher, and
Student.

If the user chooses Teacher, I would like the combo box list to be limitted
to only certain records from the lookup table. However, if the user chooses
the Student radio button, I would like the combo box list to include all
records from the lookup table.

I understand how to code it to include, (for example, 1, 4 & 5,) for one
option and the remainder, (2, 3, & 6,) for the other option button, but I
can't seem to see how to code it so the combo box includes only some records
for one option but all for the other.

If it would help, the controls are named as follows:
cboReason (the combo box)
ForWhatInitiate (the radio button group)

The following are the records in the tblWDReasonLOOKUP table:
1 Unknown
2 Personal
3 Course Completed
4 Course Inappropriate
5 Course Too Difficult
6 Moved Away
7 Poor Attendance


Set the combo box's RowSource to a query like:

SELECT ReasonID, ReasonDescr
FROM tblWDReasonLOOKUP
WHERE ReasonID IN(1, 4, 5)
OR Forms!theform.ForWhatInitiate = 2

where 2 is the option value for the student option button

Then add two lines of code to both the option frame's
AfterUpdate event and to the form's Current event:

Me.cboReason = Null
Me.cboReason.Requery
 
G

Guest

Brilliant!

And how painfully simple.

Our database will be online in time for semester one start now.

Marshall, I can't thank you enough...and all the pros that monitor these
community groups. You're awesome!
 

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