Results 1 to 6 of 6
  1. #1
    b.richardson is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    3

    Help Counting Records to Display on a Form or Report

    I would like to count the number of records corresponding to a specific field. I have two tables involved.

    One table [client table] contains people and a bunch of info, including the organization they are associated with.
    Second table [agency table] contains details about agencies.

    When filling in details about a client, users can pull an agency name from a drop down, which comes from [agency table].

    I also have a form for adding new agencies. On that form, I would like to add a field that displays the number of records, from the [client table], of people assigned to the specific org displayed on the form at that time.

    For instance, if the user is looking at the all the info for Agency A, there would be a field that says "Number of Active Clients", which would count the number of records from the [client table] with a user assigned to Agency A.

    I hope that makes sense. Sorry if it's too much info. This is my first "phone-a-friend" lifeline request and I want to give as much info as possible to hopefully get some help. Thanks in advance!!

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Look up DCount function.

  3. #3
    b.richardson is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    3
    I figured it would be DCount. Should have said that. I've tried using it but just get #Error. I'm not sure how to tie the field on the form to the field in the table, or if that's even possible.
    Here's what I've tried: =DCount("[tblFullClientList.PrimaryAgencyAssigned]","tblFullClientList","[fldPrimaryAgencyAssigned] = Forms!frmAgencyInfo!fldNonProfitCivicOrgName")

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    What error are you getting? That looks like it should work as far as the syntax.

  5. #5
    b.richardson is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    3
    When I open the form, the field just says "#Error". I don't get any errors when I build the expression. I thought maybe I had a reference wrong or something since it seems the calculation isn't working (at least I think that's what's happening based on the #Error in the field. Thanks!

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    If everything is on the same form
    Code:
    =DCount("[PrimaryAgencyAssigned]","tblFullClientList","[fldPrimaryAgencyAssigned] = '" & [fldNonProfitCivicOrgName] & "'")






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

Similar Threads

  1. Display a count of records on Form or Report
    By rdougherty in forum Access
    Replies: 6
    Last Post: 03-14-2017, 03:26 PM
  2. Counting Records to display on Form
    By Ekhart in forum Forms
    Replies: 1
    Last Post: 08-01-2016, 10:13 PM
  3. Counting records in report from a select field
    By LaughingBull in forum Access
    Replies: 5
    Last Post: 08-23-2015, 12:09 PM
  4. Exclude duplicate records when counting in a report
    By Fuzz_cozens in forum Reports
    Replies: 8
    Last Post: 02-14-2014, 02:16 AM
  5. Replies: 1
    Last Post: 11-11-2006, 08:00 PM

Tags for this Thread

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