Results 1 to 6 of 6
  1. #1
    chavez_sea is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    105

    Union Query

    Good day ,


    I am trying to customize a union query someone made for me a long time ago.

    SELECT Previous Billing.*, Current Billing.Previous Balance Due AS PreviousBalance, NULL AS Current Balance Due
    FROM Previous Billing
    UNION ALL SELECT Current billing.*, NULL AS Previous Balance Due, Current billing.Current Balance Due AS Current Balance
    FROM Current billing;
    I have two queries with field names as follows:
    query named Current Billing with field current balance due
    query named Previous Billing with field previous balance due

    I am getting a syntax error in previous billing but cant see the error.

    Grateful for assistance


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    i find it easier to make my individual queries and not have to debug 1 massive union query:
    select * from Query1
    union
    select * from Query2

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The spaces in your names are not advisable and have to be bracketed when used, like:

    [Previous Billing]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    chavez_sea is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    105
    Thanks. So in this case how would my query look. I am not good at union queries.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If that's directed at me, either get rid of the spaces in your object names (preferable) or put square brackets around any table/query/field name that has one or more spaces in it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    chavez_sea is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    105
    Thank you. Will amend and see how it works.

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

Similar Threads

  1. Replies: 3
    Last Post: 11-29-2018, 03:18 PM
  2. Replies: 4
    Last Post: 08-09-2017, 12:06 PM
  3. Convert Union Query to non-union help
    By Ekhart in forum Queries
    Replies: 2
    Last Post: 01-10-2017, 03:39 AM
  4. Replies: 4
    Last Post: 12-20-2015, 02:35 PM
  5. Replies: 8
    Last Post: 10-22-2012, 07:43 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