Multiple selections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a column consisting of 4 different items. Sometimes to compare
certain data I want to select 2 of those items. For example I have the
following items in column B: Green, Yellow, Red, Blue. How would I go about
selecting the red and blue items?
 
In a query you can use the IN operator, e.g.

SELECT *
FROM MyTable
WHERE ColumnB IN ("Red", "Blue");

In query design view you'd just enter IN("Red", "Blue") in the criteria row
of ColumnB.

The IN operator does not accept parameters however, so if you wanted to
include parameters in the query so that you are prompted for the colours when
opening the query you'd have to use Boolean OR operation:

SELECT *
FROM MyTable
WHERE ColumnB = [Enter First Colour:]
OR ColumnB = [Enter Second Colour:];

In query design view you'd do this by entering [Enter First Colour:] in the
first Criteria row for ColumnB and [Enter Second Colour:] in the second row.
If you base a form or report on this query you'd be prompted for the colours
when you open the form or report.
 
OK this is a stupid question but it seems a query only aplies to external
data. Is this true, and if not how do you start a query on Excel data?

Ken Sheridan said:
In a query you can use the IN operator, e.g.

SELECT *
FROM MyTable
WHERE ColumnB IN ("Red", "Blue");

In query design view you'd just enter IN("Red", "Blue") in the criteria row
of ColumnB.

The IN operator does not accept parameters however, so if you wanted to
include parameters in the query so that you are prompted for the colours when
opening the query you'd have to use Boolean OR operation:

SELECT *
FROM MyTable
WHERE ColumnB = [Enter First Colour:]
OR ColumnB = [Enter Second Colour:];

In query design view you'd do this by entering [Enter First Colour:] in the
first Criteria row for ColumnB and [Enter Second Colour:] in the second row.
If you base a form or report on this query you'd be prompted for the colours
when you open the form or report.

aaronwexler said:
I have a column consisting of 4 different items. Sometimes to compare
certain data I want to select 2 of those items. For example I have the
following items in column B: Green, Yellow, Red, Blue. How would I go about
selecting the red and blue items?
 
If you're working in Excel, you'd be better off asking this in a newsgroup
related to Excel.

This newsgroup is for questions about Access, the database product that's
part of Office Professional.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



aaronwexler said:
OK this is a stupid question but it seems a query only aplies to external
data. Is this true, and if not how do you start a query on Excel data?

Ken Sheridan said:
In a query you can use the IN operator, e.g.

SELECT *
FROM MyTable
WHERE ColumnB IN ("Red", "Blue");

In query design view you'd just enter IN("Red", "Blue") in the criteria
row
of ColumnB.

The IN operator does not accept parameters however, so if you wanted to
include parameters in the query so that you are prompted for the colours
when
opening the query you'd have to use Boolean OR operation:

SELECT *
FROM MyTable
WHERE ColumnB = [Enter First Colour:]
OR ColumnB = [Enter Second Colour:];

In query design view you'd do this by entering [Enter First Colour:] in
the
first Criteria row for ColumnB and [Enter Second Colour:] in the second
row.
If you base a form or report on this query you'd be prompted for the
colours
when you open the form or report.

aaronwexler said:
I have a column consisting of 4 different items. Sometimes to compare
certain data I want to select 2 of those items. For example I have the
following items in column B: Green, Yellow, Red, Blue. How would I go
about
selecting the red and blue items?
 
OK this is a stupid question but it seems a query only aplies to external
data. Is this true, and if not how do you start a query on Excel data?

I'm with Douglas here: are you using Excel alone, Excel from an Access
database, or Access? In Access, queries apply to either internal or
linked data; I believe that in Excel you're correct - but this *is* an
Access newsgroup, so I presumed that you were using Access and
answered accordingly.

John W. Vinson[MVP]
 
Back
Top