Solved

MS ACCESS - flag duplicates in to the same table

Posted on 2010-11-09
7
1,049 Views
Last Modified: 2012-06-27
(1) My ACCESS Table1 has following columns, i.e., Field1, Field2, Field3, ..., Field 10 with 750,000 records.

(2) FIELD2 is supposed to contain unique value, but somehow there are over 10,000 duplicate values in it. I found this by using

SELECT Table1.FIELD2, count(Table1.FIELD2) as CheckDupe from Table1 group by 1 where CheckDupe>1

QUESTION:
I'd like to find an effective way to
(A) Make Table1 to have extra column FIELD11 as a flag
(B) FIELD11 = "Yes" If FIELD2 contains duplicate value and "No" when it contains unique value?

I am just an intermediate MS ACCESS level.  I found that the following solution would work, but very inefficient ie.,
(i) Make a text list of dupe values in MS WORD "Value1", "Value2", ...., "Value10000"
(ii) Create an intermediate table (called Table2) from Table1 that contain only 2 fields, i.e., FIELD2 and FIELD11, where as FIELD11 = ""
(iii) write an UPDATE query like this:

UPDATE TABLE2 SET TABLE2.FIELD11 = "Yes"
WHERE TABLE2.FIELD2 IN ("Value1", "Value2", ... , "Value1000");

(iv) run this query. then replace the next thousand values, save and run. then redo this again . . . .  until all 10,000 values are covered.

The problem is 1. I have 5 other tables that have the same problem. I dont want to spend the whole week doing this.  So, Help please.
0
Comment
Question by:Paul_ATL
  • 4
  • 3
7 Comments
 
LVL 58

Assisted Solution

by:cyberkiwi
cyberkiwi earned 250 total points
ID: 34097263
Add a new column into Table1 using the UI.
Run this query (if field2 is textual)

update Table1
set Field11 = IIF(DCount("Field2", "Table1", "Field2='" & Field2 & "'")>0,true, false)
0
 

Author Comment

by:Paul_ATL
ID: 34097500
Hi cyberkiwi,

I did as suggested to add FIELD11.
Then Copy-PASTE your query in to an UPDATE querym but when run, it asks me for "parameter entry" of TABLE1
0
 

Author Comment

by:Paul_ATL
ID: 34097556
Hi cyberkiwi,

Sorry, I made some typos.

Your query runs, but when checking the result, it only updates FIELD11 with value -1 for all records.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Accepted Solution

by:
Paul_ATL earned 0 total points
ID: 34097655
Hi cyberkiwi,

I works now. I change >0 to >1
Thanks for your help. Save me lots of time.
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34097665
What type is Field2?

Another approach, make Field11 a Number field, then try this query:

update Table1
set Field11 = DCount("Field2", "Table1", "Field2='" & Field2 & "'")

Actually never mind, I see the error. It should be greater than 1...

update Table1
set Field11 = IIF(DCount("Field2", "Table1", "Field2='" & Field2 & "'")>1,true, false)
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34097685
You're welcome! Makes me happy when askers help themselves :)
0
 

Author Closing Comment

by:Paul_ATL
ID: 34130279
Great advice, just minor issue on >1 instead of >0 but I can figure this out.  But certainly, without his advice, I will NEVER figure to use DCOUNT.

Thanks a bunch
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now