473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Cause of Duplicate Records?

446 Expert 256MB
I have found that I have duplicates in my Products table. I am using the DLookup() function to find a ProductID by a product 'criteria' and only create a new one if can not find a match e.g.

Expand|Select|Wrap|Line Numbers
  1. varX=dlookup("[ProductID]","ProductsTableName", strCriteria)
  2. if isnull(varX) then
  3.       'Proceed to add new record and create new ProductID (autonumber)
  4. else
  5.       'Use ProductID currently held in varX
  6. endif
There are about 14,000 rows in the Products table, but I have found 40 are duplicates. The table started off with about half the number of records 7 years ago and there are 5 to 10 users accessing it.

The 'criteria' is a compound of 9 fields, seven of which are foreign keys populated by selecting from combo-boxes. The other two fields are text selected from combo boxes but not limited to the list. These don't seem to be the cause of the problem i.e. the duplicate records match each other perfectly on the 'criteria' fields. (They would not be duplicates if they were different !!)

With hindsight, I should perhaps have created a unique index on theses nine fields but that seemed rather cumbersome; the code should work; it's desireable but not critical to prevent duplication of products.

I've searched previous postings for a clue as to what is going wrong but most comment is about about finding duplicates and removing them. But why do they occur in the first place?
Nov 18 '07 #1
3 2173
nico5038
3,080 Expert 2GB
When you have no unique index defined on the unique combination of fields, then this can happen.
It's almost impossible to trace where this does occur without first defining the unique index and get an Access warning when trying to insert such a duplicate.

Best to start with a groupby query on the unique combination of fields and add a Count for another field. By testing for >1 the count will return the 40 dupes and will allow you to join with the original table to see all dupes. Remove the ones leaving the correct ones and add the unique index on the unique combination of fields!

Nic;o)
Nov 21 '07 #2
sierra7
446 Expert 256MB
Thanks for your reply Nico.

Yes, I found the dups much as you suggested but by using the Wizard! then I converted the query to 'make table' so I could favour one value over another, and replace the unwanted values in all the other tables that refered to ProductID.

It's years since I built the system, but I imaging that I didn't use a unique index because it must manage both Standard parts and Miscellaneous parts (or 'specials') on Purchase Orders and Sales Orders. The Standard parts should be unique and are easy to structure but the miscellaneous parts, no so.

No, I relied on the code and was now wondering if there are any issues with the dLookup() function being unreliable. The present system is in '97' and I am going through the code upgrading to '2003',(having to explicity state DAO etc). We had already hit the problem of charts not displaying correct data (See KB317155) and I was partly wondering if this may have been another issue with running '97' under XL.

An alternative is that I may be seeing a difference between Me.Fieldname and Me![FieldName], which would have consequences in the 'criteria' of my dLookup(). Generally, the names of all my controls are the same as the bound data within them . . . but this is probably a topic for another thread.
Nov 22 '07 #3
nico5038
3,080 Expert 2GB
I haven't experienced DLOOKUP() errors yet, but perhaps using fields with leading or trailing spaces could have an undesired side effect like this...

Nic;o)
Nov 23 '07 #4

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

Similar topics

2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
4
by: KT | last post by:
Is there any one click solution that would do the trick? I would like to create a button, so the person who maintains the database can perform clean up work to delete duplicate records which...
2
by: Carroll | last post by:
I'm looking for a way in SQL to find duplicate records in a single table, that are the same based on 3 columns, regardless of what is in the other columns in the duplicate records. I would like to...
0
by: B.N.Prabhu | last post by:
Hi, I have a DataTable with several rows. Its having 20 Columns. when i click the Insert button then i have to check the Database Rows. Whether these new rows are already available in the...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
4
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but,...
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
6
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
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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,...
0
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...

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.