Using a combobox to to filter info into a listbox

spnz

Registered User.
Local time
Today, 08:24
Joined
Feb 28, 2005
Messages
84
Hi there

This im sure is a easy question but I am just trying to learn access so I am having a few problems.

I have made a form that contains 2 comboboxs and a listbox.

How can I use the 2 combobox to filter a table and to place the information into the listbox.
Is it possible to use either 1 of the combo boxes or both to get the filtered result.


Any suggestions would be great!!

TIA!
 
ListBox

Here I will do...

You may put your code on the command button. Once the user click this button, it will trigger the code that will change the rowsource of the listbox.

Your code should be a sequel statement which will extract the data based on the value of the combo box, or you can create a Query where you can put your criteria in a certain field.

After you change the rowsource of the listbox, you have to do the a Referh or Requery action to update the List.
 
Spnz,

Use the AfterUpdate event of the 2nd combo to:

Code:
Me.ListBox.RowSource = "Select FieldA, FieldB " & _
                       "From   YourTable " & _
                       "Where  [SomeField] = '" & Forms![YourForm]![Combo1] & "' And " & _
                       "       [OtherField] = '" & Forms![YourForm]![Combo2] & "'"
Me.ListBox.Requery

You'll have to change the names to fit and the above assumes that the combos contain
string data.

Wayne
 

Users who are viewing this thread

Back
Top Bottom