Calculate count of records with a particular property on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mmmel
    New Member
    • Feb 2010
    • 52

    #1

    Calculate count of records with a particular property on a form

    Hi! I'm sure that this is easy, but I just can't solve it. Could you please help?

    Access 2010

    I have a form that displays all students in my program and all classes that they take, kind of like this:

    STUDENT ID CLASS MARK

    All I want to do is create a calculated field that displays the total number of classes that student is taking, like this:

    STUDENT ID #Classes CLASS MARK
    John Doe 2 Math 30 88
    John Doe 2 English 30 67
    Jane Deer 1 Physics 30 99

    and so on. I tried using the COUNT function (it says 1 each time, as these are not grouped), then I tried to do this in the query (same thing), then I tried to first COUNT them SUM them in the query (complains about subqueries and aggregate functions).

    Any ideas? Thank you in advance!

    Melody
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can either use the DCount() aggregate function or you can join to a subquery containing counts.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Try as Rabbit has suggested. If you're still banging-your-
      head-on-the-wall... we'll get thru to the other side of it!

      Another hint: You can't use multiple fields in an aggreate query when trying to do a count.

      Comment

      • Mmmel
        New Member
        • Feb 2010
        • 52

        #4
        Shall try right away! Thanks for the direction, and I'll let you know if my head is getting woozy from all the banging! : )

        Comment

        • Mmmel
          New Member
          • Feb 2010
          • 52

          #5
          Got it! The syntax took me a minute to figure out, but it's all good. Thank you so much for the suggestions, and so timely too! Much appreciated. : )

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Not a problem, good luck!

            Comment

            Working...