The creation and customization of database applications using Microsoft Access
Yes. In Access, the usual way to find records in one table that do not have matching records in another table is to create a query with a join on the common ID field, then return only the records where the related table has no match.
A practical way to set it up:
- Make sure both tables can be joined on the same ID field.
- The related fields must have matching data types.
- If creating a table relationship, the referenced table should have a primary key or unique index.
- In Access, open Create > Query Design.
- Add both tables:
- lead
- Activity
- Create the join by dragging the common ID field from lead to the common ID field in Activity.
- A line between the tables shows the join.
- Double-click the join line to open Join Properties.
- Choose the join option that includes all records from
leadand only matching records from Activity.- This is a left outer join.
- Add the fields from lead that should appear in the results.
- Add the ID field from Activity to the grid, and in its Criteria row enter:
Is Null - Run the query.
- The result will be leads that do not have a matching activity.
Why this works:
- Access uses joins in queries to combine data from related tables.
- With an outer join, all rows from lead are kept.
- Filtering the Activity side to
Is Nullreturns only leads with no related activity.
If Access shows relationship errors while setting this up, check these first:
- Both ID fields use the same data type.
- The referenced field has a primary key or unique index if a relationship is being created.
- Join tables and queries
- Compare two tables in Access and find only matching data
- Create a query based on multiple tables
- Joining tables in access - Microsoft Q&A No unique index found for the referenced field in the primary table
- Relationship must be on the same number of fields with the same data types. (Error 3368) - Microsoft Q&A