Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

You can use the UniqueValues property when you want to omit records that contain duplicate data in the fields displayed in Datasheet view. For example, if a query's output includes more than one field, the combination of values from all fields must be unique for a given record to be included in the results.

Note: The UniqueValues property applies only to append and make-table action queries and select queries.

Setting

The UniqueValues property uses the following settings.

Setting

Description

Yes

Displays only the records in which the values of all fields displayed in Datasheet view are unique.

No

(Default) Displays all records.


You can set the UniqueValues property in the query's property sheet or in SQL view of the Query window.

Note: You can set this property when you create a new query by using an SQL statement. The DISTINCT predicate corresponds to the UniqueValues property setting. The DISTINCTROW predicate corresponds to the UniqueRecords property setting.

Remarks

When you set the UniqueValues property to Yes, the results of the query aren't updateable and won't reflect subsequent changes made by other users.

The UniqueValues and UniqueRecords properties are related in that only one of them can be set to Yes at a time. When you set the UniqueValues property to Yes, for example, Microsoft Office Access 2007 automatically sets the UniqueRecords property to No. You can, however, set both of them to No. When both properties are set to No, all records are returned.

tip

If you want to count the number of instances of a value in a field, create a totals query.

Example

The SELECT statement in this example returns a list of the countries/regions in which there are customers. Because there may be many customers in each country/region, many records could have the same country/region in the Customers table. However, each country/region is represented only once in the query results.

This example uses the Customers table, which contains the following data.

Country/Region

Company name

Brazil

Familia Arquibaldo

Brazil

Gourmet Lanchonetes

Brazil

Hanari Carnes

France

Du monde entier

France

Folies gourmandes

Germany

Frankenversand

Ireland

Hungry Owl All-Night Grocers


This SQL statement returns the countries/regions in the following table:

SELECT DISTINCT Customers.CountryRegion
FROM Customers;

Countries/Regions returned

Brazil

France

Germany

Ireland


Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×