Results 1 to 3 of 3
  1. #1
    grond is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    2

    Display count of records from related subform in main form

    I have a Form, [frmMembers], with a subform, [frmMembers_Subform] which is based on a query.
    The subform displays a number of records that are related to the record from the main form, in a datasheet view.


    I want to place a control on the main form that displays the count of records returned in the subform.

    I'm not sure how to proceed. I thought I could make a calculated control to count the number of instances of each foreign key from the query, but I only succeeded in returning the total number of records returned by the query (not the number of unique foreign keys).

    Other than that, I have no idea where to go with it. My attempts to create a function to count the records from the main form have all failed miserably, with the #Name? error.

    What do?

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Add a textbox in subform's footer(say txtCount).Set =count(SomeControlonSubForm) as its control source. On the main form, add a text box and set it's control source to this text box(=[SubFormName].[Form]![txtCount]). SubFormName is the subform control's name on main form.Use the expression builder to get the correct syntax.

  3. #3
    grond is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    2
    Thanks amrut. That got it, I was just janking up the syntax.
    I was also confused because the calculated field =count([countfield]) was returning the total number of items from the query, instead of those related to the record I wanted to show, but I suppose that that changes when the main form runs and pulls out the data. Once I popped the pointer into the main form, it worked splendidly.
    Thanks again.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-19-2013, 07:06 PM
  2. Replies: 16
    Last Post: 02-13-2012, 03:32 PM
  3. Replies: 7
    Last Post: 11-07-2011, 06:31 AM
  4. Replies: 2
    Last Post: 06-17-2010, 04:15 PM
  5. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 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