Results 1 to 3 of 3
  1. #1
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48

    Do not include row in union query if field contains a 0 value

    Hi,



    I have a union query wich collects data from differents excel sheets.

    I would like the union query to exclude rows that contains a 0 in a specific field with name [Company].

    Is there a code or other function?
    If code where do I put the code?

    Br Bertrand

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Add a Where clause to each subquery in the Union query that excludes those records, i.e.
    Code:
    SELECT ...
    FROM ...
    WHERE Company<>"0"
    
    UNION
    
    SELECT ...
    FROM ...
    WHERE Company<>"0";
    
    (assuming company is a text field, if it is numeric, remove the quotes from around the zero).

  3. #3
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    Thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-25-2012, 06:54 PM
  2. Replies: 3
    Last Post: 08-04-2011, 05:39 PM
  3. Union query truncating a memo field
    By jpkeller55 in forum Queries
    Replies: 7
    Last Post: 05-27-2011, 02:17 PM
  4. union query needs new field
    By jmoore in forum Programming
    Replies: 0
    Last Post: 03-11-2011, 08:57 AM
  5. union query with a calculated field
    By grad2009 in forum Queries
    Replies: 9
    Last Post: 03-31-2010, 04:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums