filtering with listboxes?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is it possible to apply a filter to a listbox, based on a value received from
a combobox? any tips are greatly appreciated
 
justin_vasko said:
is it possible to apply a filter to a listbox, based on a value received from
a combobox? any tips are greatly appreciated

Either use a saved query as the listbox's rowsource, and have the query
look up the combo for its criterion, like:
Forms![TheFormName]![TheComboName]
and requery the listbox every time the combo changes, or use some simple
code in the combo's Change event like:

strRS = "SELECT FiedX FROM MyTable WHERE FieldY = " & Me.ComboName
Me.ListboxName.Recordsource = strRS

In the above sample code I have assumed the combo / FieldY to be
numeric; if text, then:

strRS = "SELECT FiedX FROM MyTable WHERE FieldY = '" & Me.ComboName & "'"

HTH,
Nikos
 

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

Back
Top