In my Access datebase I have a two tables:
Table1:
PersNum Name Surname
2321 Lenora Springer
2320 Donya Gugino
3326 Leland Wittmer
4588 Elmer Mcdill
Table2:
PersNum Name Surname
2321 Lenora Farney
2320 Donya Willimas
3326 Leland Wittmer
4588 Maya Mcdill
7785 Yolanda Southall
1477 Hailey Pinner
I need to find a way to check the personal number (field "PersNum"), and then if PersNum exist, update Name and Surname in Table1. If PersNum doesn't exist, insert new row in Table1.
Expected results:
PersNum Name Surname
2321 Lenora Farney (updated surname)
2320 Donya Willimas (updated surname)
3326 Leland Wittmer (without change)
4588 Maya Mcdill (without change)
7785 Yolanda Southall (new person)
1477 Hailey Pinner (new person)
I'm looking for any solutions based on SQL/VBA/DAO/ADO.
One option is an "upsert" or combined append/update query.
This old tip from Smart Access is one of my favourites: