Results 1 to 6 of 6
  1. #1
    stbeaver is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2014
    Posts
    3

    Combine Tables

    I am trying to find a specific way to combine/merge/join two tables and need some direction as to how to go about creating the query. I have two tables. Both tables have the same fields. Table A has 300 records, Table B has 50 records. There is an unique ID number field to index the two tables. The data in Table B is what I will call exception data. Every index number record in Table B is also in Table A, but the rest of the data in the other fields for that record is different. I want to create a query that combines the records of the two tables. If the index number is in Table A, but not in Table B, I want that record in the query. But if the index number is in Table B, I want the query to use the record in Table B instead of Table A. The resulting query would have 300 records. I have not been successful experimenting with queries and Googling for examples of this situation. I would appreciate some insight into how I might accomplish this with Access 2003.

  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,641
    Create a query that joins the two tables on the index number. Edit the join so it pulls all records from A. In the appropriate fields:

    Nz(TableB.FieldName, TableA.FieldName)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    stbeaver is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2014
    Posts
    3
    I can't use the Nz function. The value in Table A is never null. If there is a record in Table B with an index number 123, there will always be a record in Table A with the same index value of 123. The data for other fields for that record will be different, but never null. I just want to use the record data from Table B if it is there, Table A if its not.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You didn't try it? The Nz() is handling tableB not having a record.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    stbeaver is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2014
    Posts
    3
    I did not try it. Apparently, the right side of my brain is not working very well. That function worked beautifully. Exactly what I was trying to do. It never occurred to me to check Table B for nulls. I kept wanting to check it for data, and if present, use it. I was trying to make the solution harder than it was. Thank you very much for your expertise.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help, and welcome to the site by the way!
    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. How do I combine 3 tables into one?
    By Steven Seagal in forum Access
    Replies: 3
    Last Post: 09-18-2012, 06:54 AM
  2. combine two tables into one.
    By chad740 in forum Access
    Replies: 2
    Last Post: 08-31-2012, 01:12 PM
  3. combine two tables
    By boomkrekel in forum Access
    Replies: 5
    Last Post: 02-18-2012, 11:26 AM
  4. Combine data from 3 different tables
    By udigold1 in forum Queries
    Replies: 3
    Last Post: 06-29-2011, 12:18 AM
  5. combine three tables in a query
    By neuenglander in forum Queries
    Replies: 0
    Last Post: 08-21-2008, 04:02 AM

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