By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,461 Members | 2,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,461 IT Pros & Developers. It's quick & easy.

Filter Combo Box Using A Checkbox

P: n/a
I have a form that contains the following:

2 radio buttons (Name and Number)
1 check box (for Inactive Members)
1 combo box (list of Member names or numbers)

I use the radio buttons to populate the (unbound) combo box with
Member names or number depending on which button was clicked. In my
database I have a field that shows member status (active or inactive).
By defalut my sqlstring that sets the rowsource of the combo box only
looks at the status of active. I am trying to get it to include the
inactive members just by clicking the checkbox. Then when I uncheck
it, it would remove the inactive members. I can't seem to get this to
work. Any ideas?

Thanks,
Mark
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mark wrote:
I have a form that contains the following:

2 radio buttons (Name and Number)
1 check box (for Inactive Members)
1 combo box (list of Member names or numbers)

I use the radio buttons to populate the (unbound) combo box with
Member names or number depending on which button was clicked. In my
database I have a field that shows member status (active or inactive).
By defalut my sqlstring that sets the rowsource of the combo box only
looks at the status of active. I am trying to get it to include the
inactive members just by clicking the checkbox. Then when I uncheck
it, it would remove the inactive members. I can't seem to get this to
work. Any ideas?

Thanks,
Mark


Hown about posting you code, including the SQL string?

Nov 13 '05 #2

P: n/a
first, you have to make sure that your option buttons are not
independent, rather part of an option group. if they were created as
an option group, they'll each be assigned a value....1 or 2, in this
case. they are likely already part of an option group and you can
identify this by checking the properties. if the option buttons have
the property 'Option Value' rather than 'Control Source' they are part
of a group.

once that's done the rest should be cake. all you have to do is change
the 'Row Source' property of the combo box by writing a short
procedure for the Click event of the check box. that should look
something like this:

Private Sub chkShowInnactive_Click()

Dim strNameNumber As String

strNameNumber = IIf(Me.optNameNumber.Value = 1, "Names", "Numbers")
If Me.chkShowInnactive.Value = False Then
Me.cboList.RowSource = "SELECT MyTable." & strNameNumber _
& " FROM MyTable ORDER BY MyTable." & strNameNumber & ";"
Else:
Me.cboList.RowSource = "SELECT MyTable." & strNameNumber _
& "FROM MyTable WHERE (((MyTable.Innactive) = True)) " _
& "ORDER BY MyTable." & strNameNumber & ";"
End If

End Sub

with that in place, you may want to write a short bit of code for the
Load or Open event to set the 'Row Source' of the combo box when you
first crank the thing up, so that you're starting from the same point
each time.

HTH

ma******@Hotmail.com (Mark) wrote in message news:<57**************************@posting.google. com>...
I have a form that contains the following:

2 radio buttons (Name and Number)
1 check box (for Inactive Members)
1 combo box (list of Member names or numbers)

I use the radio buttons to populate the (unbound) combo box with
Member names or number depending on which button was clicked. In my
database I have a field that shows member status (active or inactive).
By defalut my sqlstring that sets the rowsource of the combo box only
looks at the status of active. I am trying to get it to include the
inactive members just by clicking the checkbox. Then when I uncheck
it, it would remove the inactive members. I can't seem to get this to
work. Any ideas?

Thanks,
Mark

Nov 13 '05 #3

P: n/a
Thanks for the code example, that does exactly what I wanted.

Mark
ca*********@yahoo.com (Jamey Shuemaker) wrote in message news:<42*************************@posting.google.c om>...
first, you have to make sure that your option buttons are not
independent, rather part of an option group. if they were created as
an option group, they'll each be assigned a value....1 or 2, in this
case. they are likely already part of an option group and you can
identify this by checking the properties. if the option buttons have
the property 'Option Value' rather than 'Control Source' they are part
of a group.

once that's done the rest should be cake. all you have to do is change
the 'Row Source' property of the combo box by writing a short
procedure for the Click event of the check box. that should look
something like this:

Private Sub chkShowInnactive_Click()

Dim strNameNumber As String

strNameNumber = IIf(Me.optNameNumber.Value = 1, "Names", "Numbers")
If Me.chkShowInnactive.Value = False Then
Me.cboList.RowSource = "SELECT MyTable." & strNameNumber _
& " FROM MyTable ORDER BY MyTable." & strNameNumber & ";"
Else:
Me.cboList.RowSource = "SELECT MyTable." & strNameNumber _
& "FROM MyTable WHERE (((MyTable.Innactive) = True)) " _
& "ORDER BY MyTable." & strNameNumber & ";"
End If

End Sub

with that in place, you may want to write a short bit of code for the
Load or Open event to set the 'Row Source' of the combo box when you
first crank the thing up, so that you're starting from the same point
each time.

HTH

ma******@Hotmail.com (Mark) wrote in message news:<57**************************@posting.google. com>...
I have a form that contains the following:

2 radio buttons (Name and Number)
1 check box (for Inactive Members)
1 combo box (list of Member names or numbers)

I use the radio buttons to populate the (unbound) combo box with
Member names or number depending on which button was clicked. In my
database I have a field that shows member status (active or inactive).
By defalut my sqlstring that sets the rowsource of the combo box only
looks at the status of active. I am trying to get it to include the
inactive members just by clicking the checkbox. Then when I uncheck
it, it would remove the inactive members. I can't seem to get this to
work. Any ideas?

Thanks,
Mark

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.