PDA

View Full Version : Query Criteria



kbsudhir
09-19-2008, 11:52 AM
Hi All,

I have two listbox namely list1 & list2.

Now the problem

I want to generate a query to filter out all the data which is provided in the both list1 & list2 & display the remaining data in list3

1. Can this be done..???
2. If yes, then please guide.
3. Else if there is any other way to filterout the data of the listbox form the table then & display the remaining ones then please suggest that.

Thanks
Sudhir

nepotist
09-19-2008, 12:42 PM
I believe it can be done through a unmatched query..

I can be more positive if you could explain a bit more about the list boxes are they from the same table and same field or are they on queries?

CreganTur
09-19-2008, 12:49 PM
Since you cite listboxes I guess you're working with a Form.

There are a couple of ways you can do this that I can think of off the top of my head.

You could use the selected criteria to open a second form that would display your filtered recordset. YOu would use the DoCmd.OpenForm's WHERE condition- just be sure you use the 'Not' keyword to tell it what criteria you want to exclude.
For Listbox 3- set its rowsource to the query you want to use. For the querie's criteria you can reference the first 2 listboxes via longhand: [Forms]![FormName]![FormObject]- this tells the query to look at that object to get its criteria. Be sure to use the 'Not' keyword since you want to exclude data. -- Oh, and you can always use the Expression Builder to help you drill down for the form objects you're wanting to use.HTH:thumb