Record Count

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jahangir
    New Member
    • Oct 2006
    • 22

    Record Count

    Dear Frinds,
    I want to count the number of records a query has returened. how I can do this in Ms access.
    thanks.
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Hi,

    Dcount("*","You r query name", "")

    :)

    Comment

    • Jahangir
      New Member
      • Oct 2006
      • 22

      #3
      Code:
      SELECT HeadCount.Animal, HeadCount.Gender
      FROM HeadCount
      WHERE (((HeadCount.Animal) Like "Cow"));
      How can I integrate Count field in this query

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        Code:
        Dim strSQL As String
        strSQL = "SELECT HeadCount.Animal, HeadCount.Gender " & _
        "FROM HeadCount " & _
        "WHERE (((HeadCount.Animal) Like 'Cow'));"
        DCount("*", strSQL)
        You may want to mod your WHERE clause to say either " = 'Cow'" or " Like 'Cow*'" though.
        Another issue to bear in mind, unless you're sure of the case use something like
        Code:
        "WHERE ((UCase(HeadCount.Animal) = 'COW'));"

        Comment

        • PEB
          Recognized Expert Top Contributor
          • Aug 2006
          • 1418

          #5
          Hey NeoPa you fly in the sky my frien :)

          My frien try this one:

          SELECT HeadCount.Anima l, HeadCount.Gende r, Count(HeadCount .Animal) AS Animals
          FROM HeadCount
          GROUP BY HeadCount.Anima l, HeadCount.Gende r
          Having (((HeadCount.An imal) Like "Cow"));


          :)

          Comment

          Working...