Others

How to Search and Prevent Duplicate Records in Access Forms

Ayan MasoodAyan Masood Nov 3, 2026 869 views

Question details

The user needs to set up an Access form that requires searching for an existing company name before allowing a new record to be created, in order to prevent database duplicates.

How to Search for Existing Records Before Creating Duplicates in Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Entering new company data into an Access database form while ensuring the company doesn't already exist in the system.
Observed behavior
Users currently risk creating duplicate company entries (e.g., 'Acme Ltd' and 'Acme Limited') because there is no prior search or validation step when adding new data via the form.
Before you start

Before modifying your Access form, establish a clear set of standardized data entry rules for your organization, such as how to handle common name variations and abbreviations (e.g., 'Ltd' vs 'Limited').

Solution 1Recommended

Use a Search Box and Custom VBA Function to Check Existing Records

Implement a search or combo box to verify if a record already exists, returning the existing ID if found, or generating a new one if not.

By integrating a search box or an unbound combo box into your form, you can prompt the user to search the database first. If a match is found, the system retrieves the existing record ID instead of duplicating the entry.

For more complicated imports or data entry tasks, writing a dedicated VBA function allows you to search based on specific criteria and handle name variations efficiently.

1
Add an unbound control

Open your Access form in Design View and add an unbound Combo Box or Text Box control to serve as the initial search field for the company name.

2
Set up an After Update event

Select the newly created control, go to the Property Sheet, click the Event tab, and select '[Event Procedure]' for the 'After Update' event.

3
Write the lookup function

Write a VBA script using the DLookup function to search the table. If a matching record is found, have the script navigate the form to that specific record ID.

4
Handle new record creation

If the lookup returns a null value (no match exists), configure the code to move to a new record, allowing the user to input the new company and generating a fresh ID.

Use a Search Box and Custom VBA Function to Check Existing Records
Establish Matching Rules: Always decide on your matching rules in the VBA logic—such as ignoring punctuation or treating specific abbreviations as equals—to ensure your duplicate check is accurate.
Free Microsoft Office alternative

Manage Data and Prevent Duplicates Easily with WPS Spreadsheet

While Microsoft Access is designed for complex relational databases, many data tracking and duplicate-prevention tasks can be seamlessly handled using WPS Spreadsheet. WPS Office offers a free, lightweight suite that is fully compatible with Microsoft Office formats, providing powerful data validation and duplicate highlighting tools without the steep learning curve of Access.

  1. 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and launch WPS Spreadsheet.
  2. 2. Import Your Data: Open your existing Excel or CSV data lists directly within WPS Spreadsheet without formatting loss.
  3. 3. Apply Data Validation: Navigate to the Data tab and use the 'Data Validation' or 'Highlight Duplicates' tools to instantly restrict or identify duplicate entries in your columns.
Fully compatible with Microsoft Excel (.xlsx, .xls) formats.Built-in 'Highlight Duplicates' and 'Data Validation' features to easily prevent repeated entries.Lightweight installation with a user-friendly, familiar interface.Free alternative to expensive Microsoft Office subscriptions.
microsoft office alternative - wps office

Frequently Asked Questions

How do I handle minor spelling variations when checking for duplicates in Access?

To handle minor variations, use wildcard characters (like '*') in your search queries or DCount() functions. For robust systems, consider creating a lookup table of common abbreviations (e.g., mapping 'Ltd' to 'Limited') or implementing fuzzy matching algorithms in VBA.

Why use a Combo Box instead of a Text Box for searching in Access?

A Combo Box can display existing records in a dropdown list as the user types, thanks to the AutoExpand property. This provides immediate visual feedback and significantly reduces the chance of a user entering a duplicate name in the first place.

Can I automatically delete duplicates in an Access table?

Access doesn't have a single 'remove duplicates' button like Excel. You typically need to run a 'Find Duplicates' Query to identify them, and then manually delete them or run a complex Delete Query that keeps only the record with the lowest or highest Primary Key ID.

What is the DCount function in Microsoft Access?

DCount is a built-in domain aggregate function in Access used to count the number of records in a specified set of records (a domain). It is commonly used in VBA or macro conditions to check if a specific value already exists in a table before appending new data.