Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate query results

Status
Not open for further replies.

KalEl33

Programmer
May 20, 2002
17
US
I am having some trouble with a query returning duplicate values. This is a rather general question, but does anyone know how to remedy this problem? Is there a way to filter out the duplicate entries in a report? And if so, how do I go about doing it?

Thanks for your help with such a vague question.

Sincerely,
Kal-El
 
I assume you have already looked at select distinct in your selection!
 
I am not sure if this is what you are looking for... but this is what I have done in the past (based on Microsoft help feature in Access):

Automatically delete duplicate records from a table

In this procedure, you create a copy of the structure of the table that contains duplicates, make primary keys of all the fields that contain duplicates, and then run an append query from the original table to the new table. Because fields that are primary keys can't contain duplicate records, this procedure produces a table without duplicate records.

To create a new table
In the Database window, click Tables under Objects.


Click the name of the table you want to delete duplicate records from.


Click Copy on the toolbar.


Click Paste on the toolbar.


In the Paste Table As dialog box, type a name for the copied table, click Structure Only, and then click OK.


Open the new table in Design view, and select the field(s) that contained duplicates in the table you copied.


Click Primary Key on the toolbar to create a primary key based on the selected fields.


Save and close the table.
To append only unique records to the new table
Create a new query based on the original table containing duplicates.


In query Design view, click the Query Type on the toolbar, and then click Append Query.


In the Append dialog box, click the name of the new table from the Table Name list, and then click OK.


Include all the fields from the original table by dragging the asterisk (*) to the query design grid.


Click Run on the toolbar.


Click Yes when you receive the message that you're about to append rows.


Click Yes when you receive the message that Microsoft Access can't append all the records in the append query. This transfers only unique records to your new table and discards the duplicates.


To see the results, open the table by clicking Tables under Objects in the Database window and clicking Open on the Database window toolbar.


When you're sure the new table has the correct unique records, you can delete the original table, and then rename the new table using the name of the original table.

I hope it helps.
Kamv
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top