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