473,386 Members | 1,721 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,386 software developers and data experts.

Find and show duplicate records

I have a Parts table with a PartNumber field and a ModelNumber field. The PartNumber will be unique for each part, while there may be duplicates in the ModelNumber field.

I want the Parts form to show the PartNumbers of all parts with duplicate ModelNumbers in the SameParts textbox.

Here's what I have done so far, but I might be way off...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Current()
  3.  
  4.     Dim s_Matches As String
  5.     Dim Rec As DAO.Recordset
  6.  
  7.     Set Rec = CurrentDb.OpenRecordset("SELECT [ModelNumber], [PartNumber] FROM Parts WHERE (((ModelNumber) In (SELECT [ModelNumber] FROM [Parts] As Tmp GROUP BY [ModelNumber] HAVING Count(*)>1 ))) ORDER BY PartNumber;")
  8.  
  9.     If s_Matches = Empty Then
  10.  
  11.         s_Matches = Rec!PartNumber
  12.  
  13.     Else
  14.  
  15.         s_Matches = s_Matches & ", " & Rec!PartNumber
  16.  
  17.     End If
  18.  
  19.     Me.SameParts = s_Matches
  20.  
  21.     s_Matches = Empty
  22.     Set Rec = Nothing
  23.  
  24. End Sub
  25.  
  26.  
Can anyone help? :)

CB55
Feb 29 '08 #1
2 1423
cori25
83
Hello...

You can do it this way although I think it would be much easier to create a "find duplicates query" and then have the Same Parts text box in your form pull in this data from the query you create. Essentially, this will accomplish what you are requesting.

Let me know if this approach helps.
Feb 29 '08 #2
Hello...

You can do it this way although I think it would be much easier to create a "find duplicates query" and then have the Same Parts text box in your form pull in this data from the query you create. Essentially, this will accomplish what you are requesting.

Let me know if this approach helps.
Yes, you are right, this approach was far easier. Thanks!!
Mar 3 '08 #3

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

Similar topics

3
by: Tom Mitchell | last post by:
All: I'm stumped on a query. How do I find duplicates in a table where one of the duplicates has values is a certain field and the other doesn't. For example, I have the following table: ...
3
by: Sarah Smith via AccessMonster.com | last post by:
I am creating a database of documents that need to be worked on, are int eh proress of being worked on, and have been completed. Sometimes the same document (an updated version) comes back for more...
3
by: MostlyH2O | last post by:
Hi Folks, I have a query that joins 3 tables. One of the tables (SalaryData) has data where there may be duplicate records with different dates. Of those duplicate records, I want the query to...
2
by: steevp | last post by:
Hi, Please excuse the newbie type question, but I am wracking my brains to solve what should be a simple query. I have three fields in a table F1, F2, F3. Any of the fields may contain...
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...
1
by: aknoch | last post by:
My basic situation is this - I ONLY want duplicates, so the opposite of DISTINCT: I have two tables. Ordinarily, Table1ColumnA corresponds in a one to one ratio with Table2ColumnB through a...
7
by: AccessHunter | last post by:
I am using the following code to find and delete records in a table. The logic will go through each record and if a duplicate row is found will delete it. I ran this code and it worked the first...
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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
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
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...

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.