Results 1 to 5 of 5
  1. #1
    lithium is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    72

    Counting records, that have child records?


    Okay, my database is rather large but in essence I want to be able to display a number. That number will be the amount of MainItems that have associated SubItems (in another table). I'm lacking the creative mind to figure out how to do this, seeing that each MainItem, can have several SubItems so I cannot simply just count the records in the tblSub. I know I will somehow have to iterate through each MainItem, and check to see if there is a corresponding SubItem or not and count the ones that have them.

    I'm lost, and hopefully I didn't lose you guys.

    ::EDIT::
    The number may be used to simply point out how many MainItem's do not have any SubItems listed yet. This will help management see how many items they still need to populate and attach to the MainItem.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,740
    lithium,

    For reference, when posting it is helpful to readers if you give an overview of your database and provide some contextual information. MainItem, subItem seems so nebulous and inert.
    You say you want a number, but even that is unclear.
    Consider 2 tables in a 1 to Many relationship, Family and Children. Here a Family may have 0,1 or many children.
    So a question could be --How many Family(s) have Children?
    How many Family(s) have no Children? or, How many children does each Family have?

    Could you please put some context on your question to help readers focus an answer?

  3. #3
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    This sounds like a "Find Unmatched Query Wizard" query to me. It'll tell you which items don't have corresponding subitems. If you want a count, go through the wizard so it'll build the query for you, then modify it to add the count (Totals button on ribbon).

  4. #4
    lithium is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    72
    JamesDeckert, that worked amazing! I'm still new to some of the functions on Access.

    Orange, I apologize for the lack of context in my message. I was trying to type it all out before I ran off to a meeting. I will make sure to take note of what you said for future reference in postings.

    Thanks guys!

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,740
    @Lithium,

    Not a problem. Just saying to get a focused answer, ask a direct, clear question in context.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-05-2014, 03:26 PM
  2. Parent Child records in reporting
    By Darlene in forum Reports
    Replies: 1
    Last Post: 03-22-2014, 06:49 PM
  3. Filtering Master Records and Subform Child Records
    By Nerther in forum Programming
    Replies: 6
    Last Post: 10-01-2013, 05:24 PM
  4. Replies: 12
    Last Post: 08-30-2011, 03:36 PM
  5. Delete child records with parent record
    By jpkeller55 in forum Access
    Replies: 8
    Last Post: 09-07-2010, 08:52 PM

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