Results 1 to 4 of 4
  1. #1
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    145

    Counting folders

    Thought this would be simple but I can't seem to find an answer. I want to count the number of unique values in a field and show that number on a report. The report is based on a select query that is based on a table "Videos". The records in the table have 3 fields. GBSize, VideoFilename, VideoFolderName, so there are duplicate VideoFolderNames in the records. There are approximately 5,000 files distributed between 116 folders in the table.



    I have grouping on the report that allows me to list each VideoFolderName and the number of files in that folder. I can list the folders and the number of files in each folder on the report with no issues, however I want to list the number of Folders in the report header and can't seem to figure that out. Any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Requires 2 queries. First query returns DISTINCT values for VideoFolderName. Second query counts records in first query.

    Options for report:

    1. build query object that has the DISTINCT VideoFolderName values. Then in textbox on report, DCount() expression:
    =DCount("*", "qryFolders")

    2. JOIN second query of folder counts to original table and use that as report RecordSource.

    3. base report on GROUP BY query that has file totals by folder. Then report can calc Count(*) of folders with textbox expression. Unlike report based on raw table data, this will not allow display of detail records.


    Any filtering applied to report would likely have to be repeated in the DCount() or query object.
    Last edited by June7; 10-05-2025 at 11:03 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Sep 2025
    Location
    Newport, Shropshire, UK
    Posts
    16
    To count distinct values in a table you can use a subquery which returns DISTINCT values, and then count the numbers of rows returned by the subquery:

    Code:
    SELECT COUNT(*) AS FolderCount
    FROM (SELECT DISTINCT VideoFolderName
          FROM Videos);

  4. #4
    JonathanT is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2011
    Posts
    145
    I created a query that just showed only the uniqe folder names using the code below:
    SELECT DISTINCT
    videos.VideoFolderName
    FROM
    videos;
    Then I used a text box on the report with the following expression to count the folders: =DCount("*","FolderNames")

    Thanks to all who helped.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-24-2016, 04:54 PM
  2. Hyperlink to network folders
    By smannon in forum Forms
    Replies: 1
    Last Post: 10-24-2011, 02:42 PM
  3. Deleting Folders
    By Madmax in forum Access
    Replies: 1
    Last Post: 10-05-2011, 11:02 AM
  4. Replies: 3
    Last Post: 01-25-2011, 09:50 AM
  5. Import from various folders
    By Statique in forum Import/Export Data
    Replies: 2
    Last Post: 07-02-2009, 06:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums