S
Stephen Doyle
I'm learning by doing, slowly. Is it possible to generate a query based on
data in a value list?
data in a value list?
Stephen said:I'm learning by doing, slowly. Is it possible to generate a query based on
data in a value list?
Smartin said:Not sure if this is what you mean or not...
Suppose you have a table called "Stores" that includes a "RegionID".
Maybe there are 50 regions, but you only are concerned about 5 of them.
Suppose you have a second table that enumerates the 5 important regions.
This is what I might call a "value list":
Regions.RegionID
================
8
11
14
62
100
Now you can write a query to get info about all the stores in just the 5
listed regions:
SELECT *
FROM Stores INNER JOIN Regions
ON Stores.RegionID = Regions.RegionID;
Or, another way:
SELECT *
FROM Stores
WHERE Stores.RegionID IN (SELECT Regions.RegionID FROM Regions);
Or, even more fun... info about stores /not/ in the value list:
SELECT *
FROM Stores
WHERE Stores.RegionID NOT IN (SELECT Regions.RegionID FROM Regions);
HTH
John Nurick said:Hi Stephen,
In that case I'd change the row source type to Table/Query, put the list
of types into a little table and use that in the query.
The alternative is to write VBA code that gets the RowSource from the
combo box into a string variable, reformats it (e.g. from
"Cat;Dog;Hamster;Gerbil" to "'Cat', 'Dog', 'Hamster', 'Gerbil'") and
finally interpolates it into the WHERE clause in your query.