Results 1 to 6 of 6
  1. #1
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10

    Question Add Table and Query

    good morning to all,


    I spent some time trying to add a table with a query but I can not find the result.

    I have a table1:
    Click image for larger version. 

Name:	Table1.png 
Views:	12 
Size:	15.1 KB 
ID:	33671


    and a query 1:
    Click image for larger version. 

Name:	QUERY1.png 
Views:	12 
Size:	7.4 KB 
ID:	33672

    and I want to add them, for that I'm using a union query:


    Click image for larger version. 

Name:	union.png 
Views:	12 
Size:	7.0 KB 
ID:	33673


    but with this I can not get it added, it does not overwrite the repeated values:

    Click image for larger version. 

Name:	union2.png 
Views:	12 
Size:	20.9 KB 
ID:	33674

    As you can see, values ​​are not added.

    What I want from that union is to add values, as I show in the following image.


    Click image for larger version. 

Name:	Union buena.png 
Views:	12 
Size:	13.2 KB 
ID:	33675





    Do you know how I can get to that? Could you give me some clue?


    thank you very much for everything and geetings.


  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    UNION queries are used to get all the results from 2 different sources which isn't what you need
    Not clear where the data for query 1 comes from but you need to use an UPDATE query to do this

    I can't see the full names of your fields so replace the names in RED with your full field names below
    Use [] brackets as you have spaces in the names

    Code:
    UPDATE Table1 INNER JOIN Query1 ON (Table1.[Tipa] = Query1.[Tipa]) AND (Table1.[Fallo] = Query1.[Fallo​]) SET Table1.TP = [Query1].[TP];
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by ridders52 View Post
    UNION queries are used to get all the results from 2 different sources which isn't what you need
    Not clear where the data for query 1 comes from but you need to use an UPDATE query to do this

    I can't see the full names of your fields so replace the names in RED with your full field names below
    Use [] brackets as you have spaces in the names

    Code:
    UPDATE Table1 INNER JOIN Query1 ON (Table1.[Tipa] = Query1.[Tipa]) AND (Table1.[Fallo] = Query1.[Fallo​]) SET Table1.TP = [Query1].[TP];

    Thax in advance Ridder.

    I really want to update the query, not the table. Do you think it would be fine for what I want to get, this code?

    UPDATE Query1 INNER JOIN Table1 ON (Query1.[Tipa] = Table1.[Tipa]) AND (Query1.[Fallo] = Table1.[Fallo​]) SET Query1.TP = [Table1].[TP];I really want to update the query, not the table. Do you think it would be fine for what I want to get, this code?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Sorry but that makes no sense

    A query is based on data from one or more tables - you can't UPDATE it as such.
    Modify the query SQL to get the output you want
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    scumposse is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2018
    Posts
    10
    Quote Originally Posted by ridders52 View Post
    Sorry but that makes no sense

    A query is based on data from one or more tables - you can't UPDATE it as such.
    Modify the query SQL to get the output you want

    Thanx a lot Mr. Ridder.
    Thank you very much for your patience.



    I have created a new update query, and I have put this code.
    Click image for larger version. 

Name:	new_update_query.png 
Views:	7 
Size:	6.6 KB 
ID:	33680
    Click image for larger version. 

Name:	new_update_query2.png 
Views:	7 
Size:	7.8 KB 
ID:	33681




    but the result is not the expected:

    Click image for larger version. 

Name:	new_update_query3.png 
Views:	7 
Size:	7.2 KB 
ID:	33682



    You could tell me why it does not show me the values ??
    Thanx a lot Mr. Ridder.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    The fact that there is only one field and your screenshot is for your Initio query suggests you are looking at the query datasheet before it has been executed.
    You need to save the query then run it..
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 4
    Last Post: 04-07-2018, 11:55 PM
  2. Replies: 3
    Last Post: 06-01-2017, 06:57 AM
  3. Replies: 2
    Last Post: 01-20-2014, 12:50 PM
  4. Replies: 2
    Last Post: 10-09-2012, 03:20 PM
  5. Replies: 2
    Last Post: 10-27-2009, 07:09 AM

Tags for this Thread

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