View Full Version : Query criteria from another table


sjewins
10-03-2008, 10:15 AM
Hi;

Not sure if this possible.

I have a range of product numbers from 100000 to 999999

These are broken into non-contiguous groups as departments.

Eg.

Auto 10000-259999
Paint 320000-329999,340000-349999
Flowers 330000-339999,410000-419999,590000-595000

I have a number of queries that need to only select the groups for each department so I can generate either reports or spreadsheets.

So, the Auto query would only include the range above, as would Flowers etc.

I have a number of single-record table (one for each department) that have only one field which is the text ranges for the products in that department. (330000-334999,338888,450000-459999 eg)

These ranges change from time to time and I have many queries so I was hoping for a criteria in the query like so:

where prodno is in the list of table.prodrange values

So, there are sets of numbers which define deaprtments, such that a query needs to include only those numbers that are in the set. Given 8 departments and sets that change I only want to maintain one set of sets.

I am new at this (obviously) is wnat I need possible or have I even expressed what I need clearly enough to make sense?

Any guidance appreciated.

Pat Hartman
10-03-2008, 07:42 PM
You are running into a typical problem caused by embedding meaning into a primary key field. The best solution is to add an additional field to the table that identifies the department. That way the ranges will be irrelevant and your queries can use the deptID to select the desired records.