Results 1 to 5 of 5
  1. #1
    cwillson is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    17

    Combining data into a single table, using values from alookup table


    Hi Peeps,

    Struggling with this one....

    I have two source tables, which I need to combine into a single table: Old Names & New Names.

    Old Names
    OLD ID Name
    12345 Martin
    23456 Giles
    34567 Sue
    45678 Roger


    New Names
    NEW ID Name Address
    9876 Martin 1 home house
    8765 Giles 2 home house
    7654 Peter 3 home house
    6543 Michael 4 home house

    The New Names table contains additional information about the individuals.

    I need to combine the two using the following conditions:

    1. If a name appears in both, then the single record in the target table should use the OLD ID.
    2. If a name appears in only one source table, then the single record should use the source ID (either OLD or NEW)
    3. If a name appears in bot, then the single record needs to be appended with the address information contained within New Names (but retain the OLD ID)

    Target Table
    ID Name Address
    12345 Martin 1 home house
    23456 Giles 2 home house
    34567 Sue
    45678 Roger
    7654 Peter 3 home house
    6543 Michael 4 home house

    I have created a lookup table which searches for matching names (as above), and displays both the OLD ID and the NEW ID together. I have also created an Interim Table, which lists all the IDs together with one of the following labels, OLD & NEW, OLD, or NEW.

    Lookup Table
    OLD ID Name NEW ID
    12345 Martin 9876
    23456 Giles 8765

    Interim Table
    ID SOURCE
    12345 OLD & NEW
    23456 OLD & NEW
    34567 OLD
    45678 OLD
    7654 NEW
    6543 NEW

    I'm struggling with the query that will join populate the Name and (if present in New Name) the Address for each unique individual. I've been playing around with a SELECT IIF statement, leveraging joins, which pulls the relevant information through according to the value in [Interim Table].SOURCE, e.g. if this value is OLD & NEW or NEW then the Address field should be populated from the New Name table, but I'm not having much success.

    Any help/advice would be much appreciated. I'm still very new to Access 2010 SQL, and am convinced there must be a principle, using the Lookup Table, which I'm overlooking here.

    Many thanks

    Chris

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    why wouldnt you just keep the old id?
    anyway, make a query to add the names to a table, and keep the old id (as long)
    you can then update the table from other tables using the old id.
    and still have a new id.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Yes, can be quite challenging. Names make very poor unique identifiers. Are you positive there aren't multiple people with same name?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    cwillson is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    17
    Quote Originally Posted by ranman256 View Post
    why wouldnt you just keep the old id?
    anyway, make a query to add the names to a table, and keep the old id (as long)
    you can then update the table from other tables using the old id.
    and still have a new id.
    Always great advice, thank you ranman256!

    Curiously, having not looked at this work for a few days, I arrived at the same decision this morning - to add a column to the target table which includes the new ID if the names match, then use this to enrich the old record with data from the New Name table.

    The columns in the target table have been defined to support a complex data import routine, so I'll simply need to delete this "reference" column prior to import.

  5. #5
    cwillson is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2017
    Posts
    17
    Quote Originally Posted by June7 View Post
    Yes, can be quite challenging. Names make very poor unique identifiers. Are you positive there aren't multiple people with same name?
    Tell me about it!! Unfortunately, the data standards and policies associated with creation and maintenance of records, in the multiple legacy systems from which the source data is coming, has been horrendous. The result is that the only key I have to go on is the name...and even this, being a free text field, requires fuzzy logic to determine matches.....

    ...I'll be very glad when this phase of the project is over....!! lol

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

Similar Threads

  1. Replies: 5
    Last Post: 08-25-2015, 08:39 AM
  2. Replies: 3
    Last Post: 06-25-2013, 10:57 AM
  3. Replies: 6
    Last Post: 01-13-2012, 09:17 AM
  4. Combining 3 update queries for a single table
    By Grahamiwa in forum Queries
    Replies: 1
    Last Post: 05-13-2011, 02:35 PM
  5. Replies: 1
    Last Post: 08-21-2009, 06:52 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