Computing.Net > Forums > Database > ACCESS Record Merge

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ACCESS Record Merge

Reply to Message Icon

Name: dustyjnz
Date: December 11, 2007 at 06:54:30 Pacific
OS: Windows XP
CPU/Ram: Centrino
Product: Dell
Comment:

I have an issue that seems like it could be resolved by sql code or query. I have a simple, one table access database (contactfirstname, contactlastname, address, city, state, zip). I have many situations where there is a contact at address x in one record and then I have another contact that is also at address x (spouse) in a different record. I want to merge the two contacts and create one new record that has contact1firstname, contact1lastname, contact2firstname, contact2lastname, address1, city, state, zip. This would cut my database almost in half.

Can anyone help shed some light on this? I am intermediate with access but can't figure it out. Thanks in advance for any assitance.



Sponsored Link
Ads by Google

Response Number 1
Name: mdow
Date: December 11, 2007 at 13:12:10 Pacific
Reply:

First I would say this is something you should not do. What you have is a one to many relationship. One address with many contacts. If you have 2 tables, you could create a form that cycles through each address and a subform that displays each contact at one address. You would relate the records by having a foreign key in the Contacts table.

Having said that, if you still want to do what you asked, you would need to add the additional columns to your table, run an Update query, then a delete query.



0

Response Number 2
Name: scorpiomailin
Date: December 14, 2007 at 12:56:05 Pacific
Reply:

interestingly enough, I have a same problem, I have a table in Access. which looks like following,
D | X
----------
A b
A c
A d

Ideally, I would like to end up with a table like following,
D | X | X_1 | X_2
-----------------
A b c d

The post above says i would end up with more coloumns but i would appreciate if someone could reply in more detail

Thanks,

Scops


0

Response Number 3
Name: mdow
Date: December 17, 2007 at 11:13:16 Pacific
Reply:

You start with a table named myTable such as:
D | X
----------
A b
A c
A d

Modify table to:
D | X | X1 | X2
-----------------
A b
A c
A d

Write a query to index all values of column D.
SELECT (SELECT COUNT(*) FROM myTable WHERE myTable.X < mt2.X)+1 AS INDX, myTable.D, mt2.X
FROM myTable INNER JOIN myTable AS mt2 ON myTable.X = mt2.X;

End up with this:
INDX D X
1 A b
2 A c
3 A d

Write an update query to populate X into X1 where index = 2

UPDATE myTable INNER JOIN Query1 ON myTable.D=Query1.D SET myTable.X1 = Query1.X
WHERE (((Query1.INDX)=2));

End up with this:
D X X1 X2
A b c
A c c
A d c

Write an update query to populate X into X2 where index = 3

UPDATE myTable INNER JOIN Query1 ON myTable.D=Query1.D SET myTable.X2 = Query1.X
WHERE (((Query1.INDX)=3));

End up with this:
D X X1 X2
A b c d
A c c d
A d c d

Now write a delete query to remove duplicate records.

DELETE myTable.*, myTable.X1, myTable.X2
FROM myTable
WHERE (((myTable.X1)=[X])) OR (((myTable.X2)=[X]));

End up with this:
D X X1 X2
A b c d


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: ACCESS Record Merge

Access/Word Merge Problem - Help! www.computing.net/answers/dbase/accessword-merge-problem-help/277.html

Access/Word Merge, XP/Vista issue www.computing.net/answers/dbase/accessword-merge-xpvista-issue/539.html

Ms Access records www.computing.net/answers/dbase/ms-access-records/166.html