Results 1 to 2 of 2
  1. #1
    witooldas is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    13

    Union ALL problem

    Hi there,

    I have a question about Union ALL function.

    In then Database I have two tables.


    In first table "Data" I have a shops with address and etc. At the second table "Sub Data" I have names of premises. Tables are connected by Data.ID and [Sub Data].data_ID.

    Now, I want to show all record in one query where Data.ID and [Sub Data].ID will be in one column. I did that with “Union ALL” function, but the problem is that I can't now edit records.

    The problem is that I have split form which displays all orders, but to know who is writing I must to union tables with all existing objects and then search in it to display in form address and etc..

    Example:

    “Data” table:
    |ID | Address | Type | etc | Engineer_ID |
    ------------------------------------------------------------------------------
    |X010 | Vilnius, Vilnius str. 7 | XXX | ... | 2 |
    |X020 | Vilnius, Kaunas str. 8 | XX | ... | 1 |
    |X030 | Vilnius, Gediminas str. 9 |Warehouse| ... | 2 |

    “Sub Data” table:
    | ID | Type |Data_ID|
    -------------------------
    |X011|Bakery | X010 |
    |X021|Cookery| X020 |

    So with Union ALL funcion I union those 2 tables:
    SELECT
    Data.X,
    Data.Address,
    Data.Type,
    ...
    ...
    Data.Engineer_ID
    FROM Data

    Union ALL
    SELECT

    [Sub Data].X,
    Data.Address,
    [Sub Data].Type, Data.Energ_Imone,
    ...
    ...
    Data.Engineer_ID
    FROM Data RIGHT JOIN [Sub Data] ON Data.ID = [Sub Data].[Data_ID];


    |ID | Address | Type | etc | Engineer_ID |
    ------------------------------------------------------------------------------
    |X010 | Vilnius, Vilnius str. 7 | XXX | ... | 2 |
    |X020 | Vilnius, Kaunas str. 8 | XX | ... | 1 |
    |X030 | Vilnius, Gediminas str. 9 |Warehouse| ... | 2 |
    |X011 | Vilnius, Vilnius str. 7 |Bakery | ... | 2 |
    |X021 | Vilnius, Kaunas str. 8 |Cookery | ... | 1 |

    Maybe someone knows how can I union two tables, but still will be able to edit records.

    Thanks a lot

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I think you will get better and meaningful advice if you describe exactly what you are trying to do. The Union ALL is a HOW you might do whatever it is you are trying to do, Focus on What, not How, and I'm sure others will offer advice once they understand your situation.
    Perhaps you could post a jpg of your Tables and relationships.

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

Similar Threads

  1. union query needs new field
    By jmoore in forum Programming
    Replies: 0
    Last Post: 03-11-2011, 08:57 AM
  2. Union Query
    By jlclark4 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 08:21 PM
  3. Union Query Help
    By jo15765 in forum Queries
    Replies: 7
    Last Post: 01-06-2011, 05:46 PM
  4. Please help me out with union query
    By radicrains in forum Access
    Replies: 1
    Last Post: 10-29-2010, 01:48 AM
  5. Need help with a Union Query
    By jdowdy in forum Access
    Replies: 1
    Last Post: 10-13-2009, 05:24 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