Avoiding importing duplicate values into Access

misericordiam23VBA

New Member
Joined
Jul 21, 2022
Messages
1
Office Version
  1. 365
Hi all,

I would appreciate anyone who can help out with the following. I have a code to import an excel file into access on a daily basis (each day, an excel file is imported with that day's 100 deals).

I'd like to avoid a situation where one might accidentally import the deals that are already there (duplicate values).

Could we write a VBA code to check the "DD/MM/YYYY" column from these imported files and avoid importing if theres a duplication?

Thank.you all so much!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to the Board!

One way is to set a Primary Key (or Composite Primary Key) that only allows unique values into the table (based on one or more fields).
Then, if you try to import duplicate values, they will reject out and not be added to the table.
See: Add or change a table’s primary key in Access.

Alternatively, you could import the records into a "Temporary Import Table", and then do an Unmatched Query between the Temporary Table and your Final Table, to filter out all duplicate records.
Then change the query type to an Append Query to add the new records to the Final Table.

I have used VBA/Macros before to automate a lot of these steps, i.e.
1. Delete all existing Data from Temporary Table
2. Import new data into Temporary Table
3. Run Unmatched/Append Query to add new records to Final Table
 
Upvote 0

Forum statistics

Threads
1,215,619
Messages
6,125,875
Members
449,267
Latest member
ajaykosuri

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