When you set the
UniqueRecords property to
Yes, Microsoft Access includes the DISTINCTROW predicate in the SQL statement of the query. The DISTINCTROW predicate retrieves unique records in a multi-table query where fields have only been selected from the one-sided table in the query.
For example, if you add both the Customers and Orders tables to a query, but only select fields from the Customers table, the query returns multiple rows for each customer who placed multiple orders. When you set the
UniqueRecords property to
Yes, the query returns only one occurrence for each customer as long as that customer placed at least one order.
Steps to Reproduce Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.
- Open the sample database Northwind.mdb.
- On the Tools menu, click Relationships.
- Double-click the line representing the relationship between the Customers and the Orders tables.
- Verify that referential integrity is being enforced.
- Click to select the Cascade Delete Related Records check box to enable cascade deletions.
- Click OK to close the Edit Relationships dialog box.
- Close the Relationships window.
- Click Queries under Objects, and then click New.
- Click Design View, and then click OK.
- Add the Customers and the Orders tables to the query, and then click Close.
- On the Query menu, click Delete Query.
- Drag the asterisk (*) from the Customers table to the first column of the query design grid.
- On the Query menu, click Run.
Note that you receive the following error message:
Could not delete from specified tables.