Background: I have a table that doesn't have unique records but it should. The only way to make the records unique is to combine 2 fields in an index. I've done that, but it won't let me make the index Unique because it says I have duplicate records. I don't see any.
Before modifying the table with the 2-column index, I had created this query:
Running the query, I just don't see the duplicates.Code:SELECT tblStoreProducts.UPC, tblStoreProducts.ProductKey, Product.ProductName, tblStoreProducts.StoreProductKey, tblStoreProducts.StoreKey FROM Product INNER JOIN tblStoreProducts ON Product.ProductKey = tblStoreProducts.ProductKey WHERE (((tblStoreProducts.UPC) In (SELECT [UPC] FROM [tblStoreProducts] As Tmp GROUP BY [UPC] HAVING Count(*)>1 ))) ORDER BY tblStoreProducts.UPC;
Someone has suggested that I need to somehow change the Group By to group by the fields that will be grouped in the index (StoreKey and ProductKey). I have no idea how to do that.
Here is the issue. I have a table (Product) that contains 1 unique entry for every UPC. Information unique to that product is stored here. The UPC is unique, and ProductKey (an Autonumber field) is the primary key
I have another table (tblStoreProducts) that keeps track of which products are in a particular store. UPC is not unique, as it will occur in this table as many times as there are stores that carry that UPC. Likewise, ProductKey is not unique, for the same reason.
StoreKey is the store identifier. It, again, is not unique in this table as one store will have hundreds of product and thus an entry in that store for each product.
I created an 2-field Index on StoreKey and ProductKey but Access says I have duplicates so it won't let me make that a unique index.
How do I tweak the above query to find the duplicates? It appears to me that it's just showing me each store that a particular UPC exists in.
The only reason I have it linked to the Product table is so that I can pull in the product name to the results so I know what products we are dealing with.
Any suggestions?
Marcie