Results 1 to 2 of 2
  1. #1
    naveehgreen is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2010
    Posts
    2

    Union Query (choosing between two fields)

    I'm trying to combine a few queries with a union query and was wondering if something like this scenario is possible to code:

    Basically, there is an ID field (column 1) that I've already put in place and then I have two fields of values to choose from (Field A and Field B) so that I will end up with two columns in total. If Field A = 0, I'd like the query to take the value from Field B and multiply it by -1 and have that be the value in column 2. If there is already a value besides 0 in Field A, I'd like the query to take that value.

    Also, if the ID field is blank or is labeled 'Excluded,' I'd like the query to leave those rows out.

    Any help you can provide would be great.

    Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You can use an IIf():

    IIf(FieldA = 0, FieldB * -1, FieldA)

    You can add a WHERE clause to exclude records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 05-21-2010, 03:57 PM
  2. union query with a calculated field
    By grad2009 in forum Queries
    Replies: 9
    Last Post: 03-31-2010, 04:50 PM
  3. Need help with a Union Query
    By jdowdy in forum Access
    Replies: 1
    Last Post: 10-13-2009, 05:24 PM
  4. Create table out of union query
    By DKruse1969 in forum Queries
    Replies: 2
    Last Post: 08-28-2009, 09:55 AM
  5. Replies: 0
    Last Post: 12-28-2008, 01:56 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