modifying data in a table (deleting/adding records) access 2013

Bassem

New Member
Joined
Jun 29, 2015
Messages
23
Hello,

I'm trying to find a way to update a table that I have with new information. The thing is that the old table is a table that has a field that needs to be manually updated and I don't want to lose that...

What I would like to do is add the new records from the new table into the old one and also delete the ones that are no longer relevant (no longer showing in the new table) but keep the ones that are matching without any changes so that my manually updated field doesn't get affected. Example below:

Old Table:


Field 1
Field 2
Field 3 (Manually updated)
1
a
Yes
2
b
No
3
c
No
4
d
Yes
5
e
No
6
f
Yes
7
g
No
8
h
No
9
i
Yes
10
j
Yes

<tbody>
</tbody>


New Table:


Field 1
Field 2
6
f
7
g
8
h
9
i
10
j
11
k
12
l
13
m

<tbody>
</tbody>


Hoping to update the old table by using the new table into:

Field 1
Field 2
Field 3 (Manually updated)

<tbody>
</tbody>
6
f
Yes
7
g
No
8
h
No
9
i
Yes
10
j
Yes
11
k
12
l
13
m

<tbody>
</tbody>


Needed result: Records 1-5 in old table are no longer relevant so they get deleted and rows 11-13 in new table are now added to the old table while keeping record 6-10 and their corresponding manual entries (Yes/No) the same without having to do the manual update again

I have tried using an append query (not very familiar with it) to solve my problem but it seems to be giving me the opposite of what I'm looking for.

Thanks to anyone who can help.

Regards,
 
When I run the sql code that you sent, it is asking to enter parameter value for Table1.Field1

I think it's still missing something
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Do you have both tables in the grid. This is difficult to diagnose now without seeing your db. Can you post your db (or reasonable facsimile/sample file that is representative) to box.net or dropbox for analysis. It has reached the point where it is a guessing game because we don't have all the facts.
 
Upvote 0
I'm currently at work and we have restrictions for accessing these websites. Will hopefully try to upload my db in the evening from my personal laptop.

Thanks for bearing with me.
 
Upvote 0
Eventually we got it to work with a bit of help from a friend of mine.

Thanks for pointing me in the right direction Alan.

Regards,
 
Upvote 0
You are welcome. For the benefit of others who may have a similar issue at some time in the future, would you post your solution.
 
Upvote 0
Yes sure.

I had to use two action queries to achieve this. One append and one delete.

For the append query in design view the joint was the problem. The arrow had to be from the Field1 in the new info table to the Field1 in the main table. For the columns I chose Field1 & Field2 from the new info table and Field1 (with a criteria: Is Null) from the main table.

For the delete query in design view I only had the main table and used the Field1 column from it. For the second column I used a formula DLookUp("[Field1]","tbl_New Info","[Field1]=" & [Field1]) also with a criteria: Is Null

I didn't write these with SQL but I will paste it here in case it might help someone.

Append Query:
INSERT INTO [tbl_Main table] ( Field1, Field2 )
SELECT [tbl_New Info].Field1, [tbl_New Info].Field2
FROM [tbl_Main table] RIGHT JOIN [tbl_New Info] ON [tbl_Main table].Field1 = [tbl_New Info].Field1
WHERE ((([tbl_Main table].Field1) Is Null));

Delete Query:
DELETE [tbl_Main table].Field1, DLookUp("[Field1]","tbl_New Info","[Field1]=" & [Field1]) AS N
FROM [tbl_Main table]
WHERE (((DLookUp("[Field1]","tbl_New Info","[Field1]=" & [Field1])) Is Null));


Hope it helps :)
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top