Data Import & Export

Prevent Duplicate Field Pairs in a Microsoft Access Append Query

Khadija KhanKhadija Khan Nov 27, 2026 869 views

Question details

Add purchase-order records only when their Sales Document and Item combination is not already in the destination table.

Prevent Duplicate Field Pairs in a Microsoft Access Append Query
Product
Microsoft Access
Device & OS
not provided
Scenario
An append query maps Sales Document and Item from purchase-order records to SalesNumber and LineNo in a destination table.
Observed behavior
Each SalesNumber and LineNo pair should occur only once in the destination table.
Before you start

Confirm that the append query maps Sales Document to SalesNumber and Item to LineNo. Check the destination table for existing duplicate SalesNumber and LineNo pairs, because Access cannot create a unique index until those duplicates are resolved.

Solution 1Recommended

Create a composite unique index on the destination fields

Use a two-field unique index to prevent duplicate SalesNumber and LineNo combinations from being added to the destination table.

The index enforces uniqueness for the combination of both fields, rather than requiring each field to be unique on its own.

1
Open the destination table

In the Access Navigation Pane, right-click the destination table and select Design View.

2
Open the index list

On the Table Design tab, select Indexes to open the index list.

3
Add both fields to one index

In a blank row, enter an index name and select SalesNumber in the Field Name column. On the next row, leave Index Name blank and select LineNo as the Field Name.

4
Make the index unique

Select the named index row and set Unique to Yes in Index Properties. Close the Indexes window and save the table.

5
Run the append query

Open the append query, confirm its field mappings, and select Run. Access reports key violations for records whose field pairs conflict with the unique index.

Create a composite unique index on the destination fields
Review append results: Access may append valid records while rejecting records with duplicate pairs. Review the query results and any key-violation message before running it again.
Free Microsoft Office alternative

Review Purchase-Order Data in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility for an easy transition. Use WPS Spreadsheets to review purchase-order data exported to a spreadsheet; the Access unique index must still be created in Microsoft Access.

Review Sales Document and Item columns in a spreadsheetOpen and edit Microsoft Excel XLSX filesUse a familiar spreadsheet interfaceWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Can the same SalesNumber appear on more than one record?

Yes. A composite unique index permits the same SalesNumber on multiple records as long as each SalesNumber and LineNo combination is unique.

Why can't Access create my unique index?

The destination table may already contain duplicate SalesNumber and LineNo pairs. Find and resolve those duplicates, then return to Design View, open Indexes, and set the index's Unique property to Yes.

What happens when the append query encounters a duplicate pair?

The unique index prevents that record from being added, and Access reports a key violation. Other valid records may still be appended.

Does WPS Office enforce the unique index in my Access database?

No. Create and manage the composite unique index in Microsoft Access. WPS Spreadsheets can help you review exported purchase-order data in an XLSX file.