Share via

Count of Unique Values

Anonymous
2017-04-14T16:36:22+00:00

I have a table with 1355 records.  When I run a query, such as

Select Distinct TableName.FieldNameX

From TableName

I get 1177 records.  This will of course change as records are added or removed through a form.  There are 12 fields total.

I would like to add a control to the form that displays the number of unique values in TableName.FieldNameX.

I have used the distinct query shown above as the source for a control to show the total unique records, but it always reverts to the total records not the number of unique records.

Example, if I have a zip code table for 30 cities, with 350 rows, and a form to add more zip codes, as needed, I want a contol on the form to indicate the number of cities, not the number of zip codes.

Thank you

Hugh

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2017-04-14T17:27:01+00:00

    Create a query:

    SELECT DISTINCT fieldname FROM tablename;

    To return the count use:

    DCount("*","queryname")

    Was this answer helpful?

    0 comments No comments