Trying to Create a cascading filter system

T

takeagoodlook911

Hello,

Using MS Acess 2003 I have a set of records that are identified with
common and different traits. For example lets say I have 6 records
that are related to apples and 2 that are related to oranges.

Lets say i query for the 6 records related to apples. Within these
records are other sub ways to identify them. For example 2 of the 6
apples were made in florida.

How can I develop a way to take the results of one query and use them
to query another trait.
 
B

BruceS

If you're dealing with queries only (versus filtering for a form to display
the data), you can query a named query. For example, qry1 returns "apples"
or "oranges" by using the following SQL code:

SELECT * FROM myTbl WHERE myFruit = 'apples';

To get the Florida apples, the second query selects from the first:

SELECT * FROM qry1 WHERE myState = 'FL';

If using straight SQL, you can build the SQL string based upon variable or
control values, e.g.:

mySQL = "SELECT * FROM myTbl WHERE myFruit = '" & _
cboFruit & "'" & _
IIF(CboState > "", " AND myState = '" & cboState & "'","")
& ";"

If the query is strictly for limiting records displayed by a form or report,
use the
Filter property in a similar manner.

Either way, I usually put all of this in a function that tests all of the
filtering controls and returns the filter or SQL to use, e.g. Me.Filter =
SetMyFilter() or mySQL = GetSQL()

Bruce
 

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

Top