473,503 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting Duplicate Records in Access 2016

1 New Member
Hey Forum!

In my project there is a table containing archival data. This table currently has more than 3 million records covering a period of 11 years. Each month our team scans equipment for inventory. Unfortunately, many times during the month the same piece of equipment is inventoried multiple times. What I am looking to do is to delete records in which the serial # is inventoried more than once in the same month and year.



Any help is greatly appreciated!
May 16 '22 #1
3 27075
zmbd
5,501 Recognized Expert Moderator Expert
Good Morning EverettMiller - Welcome To Bytes.

I cannot stress enough that you create a backup of your database AND a working_copy of your database before attempting anything suggested here...

Instead of deleting your records initially from such a huge data-table I propose that you use a "Make Table" query
I've attached a simple example where I take a group_by query where it finds the first entry (based on the smallest primary key value whereas you could possibly use the date/time field given that primary keys really shouldn't have any significance as related to the record data)
Two tables - one with the assets one with the pseudo-scan
five queries - only two qry_ReturnFirstOfEntries and MakeTable_qry_ReturnFirstOfEntries are of any concern.
The first is the logic I used to return the records of interest. I tend to make simple select queries first to make sure the returned data is correct.
The second is the actual action query that creates a table named tbl_CleanDataSet within the current database, you can of course have it create a new table in a new database - which is what I would most likely do... see below.
(oh, the other queries, I was just playing and thought you might find them relevant to something else later down the road)


Delete the tbl_CleanDataSet and rerun the maketable action query. Access will delete and remake the table automagically... but what's the fun in that ?

Why this approach,
Once you have tbl_CleanDataSet you have a chance to go back against the original data table to be sure that all of your records are there that you need to have from the original data table. Once sure, then rename the orginal to something like OLD_tbl_data, rename the [tbl_CleanDataSet]![MinDataPK] to [tbl_CleanDataSet]![data_pk] and finally rename tbl_CleanDataSet to tbl_data
Once you're all happy happy - delete the old record table - Did I mention - make sure you have a backup first ?!!
(this will all make sense when you open the Database 😊 )

Now what I might do is the following...
1) Create a secondary database that holds all of the raw scans
2) Run the maketable action query in the secondary database to create the clean data set
3) From the production database run an append action query to bring the cleaned data into the production records
4) Once the new records are appended to the production records delete the records in the secondary database holding table.
4a) why use a holding table? Access likes to bloat so you can compact and/or create a new secondary database as needed without putting the production records at risk.

Ideally you would have a business rule that prevents duplicate scans of the same asset within the same month of the same year... working on that... for my databases I usually use VBA to see if the item already has an entry; however, I'm not dealing with millions of records!
Perhaps you can start a new thread detailing how the business is "scanning" the assets - maybe some logic that can be enforced without a huge lagg in data-entry.

> Neopa or Rabbit will be along shortly - they might have a better solution... usually do 👾
Attached Files
File Type: zip 977310.zip (58.0 KB, 54 views)
May 17 '22 #2
zmbd
5,501 Recognized Expert Moderator Expert
@Jimmywick
I am well aware of the find duplicates wizard and might have suggested it for a smaller data-set
The method I proposed is inherently safer in a production database in that it preserves the original dataset
1) Preservation of the original dataset is paramount when dealing with such a large amount of data just in case some needed record is in advertently deleted, or worse, the dataset is corrupted
2) Preservation of the original dataset may be required under certain federal and/or state laws, i.e. sarbanes-oxley act, certain FDA requirements, and/or ISO/ASTM or other accrediting bodies.
3) The find duplicates wizard is not usually very optimized for such large datasets
Jul 21 '22 #3
jameswalter
4 New Member
On the Design tab, click Run. Verify that the query returns the records that you want to delete. Click Design View and on the Design tab, click Delete. Access changes the select query to a delete query, hides the Show row in the lower section of the design grid, and adds the Delete row.

Regards,
Jimmy
Oct 28 '22 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4068
by: Ross | last post by:
i have less hair now than i used to...i have a database with many duplicate records in it with only one exception, there is one field with the date it was put in the database and that is different....
2
5548
by: Emmett Power | last post by:
Hi, I have an Access table with a number of records which refer to the same person but with data in different fields. So for example the table would look like this: Name..............Field...
3
5194
by: skennd | last post by:
Here's my problem in exact replication: I have used the find duplicate query in Access, and the query determined the following duplicate values by the following query: In (SELECT FROM As...
2
2022
by: vinod | last post by:
dear friends, suppose i've one table, it has only to rows.the two rows are are same as it is.how can i delete one row from that table? thank you verymuch
11
3648
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
3
1754
by: pbrown | last post by:
Hi. I'm a relatively new Access 2000 user, and I've got a problem thats got me stumped. I have a table of street addresses and property numbers that looks something like this: Name, Location,...
3
1596
matrekz42
by: matrekz42 | last post by:
Hello Guru's (DELETE QUERY) I have a table that has an account number field and a dollar amount associated with that field. I want to delete one of the fields only, if the dollar amount is the...
6
5917
by: Dilip1983 | last post by:
Hi All, I want to delete duplicate records from a large table. There is one index(INDEX_U1) on 4 columns(col1,col2,col3,col4) which is in unusable state. First of all when i tried to rebuild...
1
4090
watertraveller
by: watertraveller | last post by:
Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and...
0
2183
by: madhavateja | last post by:
i want remove duplicate records from the base table with out using rowid concept.i have one solution this is.. first selecting unique records from the table. now creating a new table with this...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.