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

Restricting combobox to Filtered Form

P: n/a
I have a form whose rowsource is a single table, i.e. 'Datasystem'.

I use a combobox to search for records in that table based on the
value of a single field, i.e., 'systemname'.

I use a multi-select listbox to filter the form on a different field,
i.e. 'domain', so that the filtered form can have several allowed values
of this field
I want to restrict my combobox to only the records in the filtered
form. I don't know how to write a query for its rowsource that will
use the selected values of the listbox to determine whether a record
is in the search space.

I'm sure I'm missing something obvious: things can't be as baroque as
I'm imagining them.

--thelma
Jan 10 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Salad <oi*@vinegar.comwrote:
: Thelma Roslyn Lubkin wrote:

<snip>

:I want to restrict my combobox to only the records in the filtered
:form. I don't know how to write a query for its rowsource that will
:use the selected values of the listbox to determine whether a record
:is in the search space.

: The code below will come close to what you need if you change the
: listbox, combobox, and field names. Just because you select something
: to filter in the listbox, you need an event to put your code in to
: update the forms filter and combobox. That's where you'd call the code
: below.

<snipped the code>

Thank you very much.

I realized after I posted this that what I really wanted to say
is how do I write a query for the combo box based not on the
field in the table, but on the form's current record set.

I will try to implement this today.

--thelma

: West India
: http://www.youtube.com/watch?v=cl4_XNa7JKI
Jan 10 '08 #2

P: n/a
Thelma Roslyn Lubkin wrote:
Salad <oi*@vinegar.comwrote:
: Thelma Roslyn Lubkin wrote:

<snip>

:I want to restrict my combobox to only the records in the filtered
:form. I don't know how to write a query for its rowsource that will
:use the selected values of the listbox to determine whether a record
:is in the search space.

: The code below will come close to what you need if you change the
: listbox, combobox, and field names. Just because you select something
: to filter in the listbox, you need an event to put your code in to
: update the forms filter and combobox. That's where you'd call the code
: below.

<snipped the code>

Thank you very much.

I realized after I posted this that what I really wanted to say
is how do I write a query for the combo box based not on the
field in the table, but on the form's current record set.

I will try to implement this today.

--thelma
If your combo can be associated with the filter, you could also try
something like
strSQL = "Select FieldName From TableName "
If Me.Filter "" then
strSQL = strSQL & "Where " & Me.Filter
'for testing
msgbox strSQL
Endif
Me.ComboName.RowSource = strSQL
>
: West India
: http://www.youtube.com/watch?v=cl4_XNa7JKI
Jan 10 '08 #3

P: n/a
Salad <oi*@vinegar.comwrote:

: If your combo can be associated with the filter, you could also try
: something like
: strSQL = "Select FieldName From TableName "
: If Me.Filter "" then
: strSQL = strSQL & "Where " & Me.Filter
: 'for testing
: msgbox strSQL
: Endif
: Me.ComboName.RowSource = strSQL

*This* is that 'obvious' solution that I was looking for.
It works.
--thelma
:>
:: West India
:: http://www.youtube.com/watch?v=cl4_XNa7JKI
Jan 11 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.