View Single Post
  #5  
Old August 28th, 2005, 05:32 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

Couple of things.

The intermediary semi-colons are wrong. Semi-colons at the end of a SQL
statement is actually optional in Access, but it's definitely not required
in the middle of the statement.

Also, the WHERE clause you've defined is only going to be applied to the
last SELECT statement, not all of them UNIONed together.

You could save your UNION query without the WHERE clause, then create a
second query that queries the UNION query, or you could use

SELECT ContId, com_name, studio FROM qry_mod_min_F4F
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_PS
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_DS
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_details
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, name, studio FROM qry_mod_insurance
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_manager
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_shift
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
ORDER BY studio, com_name;

or (assuming Access 2000 or higher) you can use

SELECT ContId, com_name, studio FROM
(
SELECT ContId, com_name, studio FROM qry_mod_min_F4F
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_PS
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_DS
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_details
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, name, studio FROM qry_mod_insurance
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_manager
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
UNION
SELECT ContId, com_name, studio FROM qry_mod_shift
) As UnionQuery
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
ORDER BY studio, com_name;


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Robert Raley" wrote in message
...
Hi Rick you suggestion worked great with the query that I was using,
thanks.

I applied the same principle to a union query that I am using and now
matter
what I input the return is all. Please take a look and tell me what I am
doing wrong. Thanks Bob

SELECT ContId, com_name, studio FROM qry_mod_min_F4F;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_PS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_min_DS;
UNION
SELECT ContId, com_name, studio FROM qry_mod_details;
UNION
SELECT ContId, name, studio FROM qry_mod_insurance;
UNION
SELECT ContId, com_name, studio FROM qry_mod_manager;
UNION SELECT ContId, com_name, studio FROM qry_mod_shift
WHERE (((studio)=[Please enter studio number] Or [Please enter studio
number] Is Null))
ORDER BY studio, com_name;