Counting Specific Records within a Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tempo
    New Member
    • Jun 2011
    • 10

    Counting Specific Records within a Table

    Using Access 2010, I would like to count all check amounts greater than $50 within a table. So far I’ve used the expression
    Code:
    = DCount("[ChkAmt]","tblChecks","txtChkAmt > 50")
    , but this expression results in “#Error”. I believe I may have a problem with the “Domain” part of the syntax. The Objects and Controls I’m using are: tblChecks (a Table); ChkAmt ( a Field); and txtChkAmt (a Text Box). I would appreciate any assistance with my issue. Thanks in advance.
    Last edited by zmbd; Jun 20 '13, 01:17 PM. Reason: [z{placed required code tags}]
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use the field in your database, not the control in your form.

    Comment

    • Tempo
      New Member
      • Jun 2011
      • 10

      #3
      Hi Rabbit! Thanks for responding. I modified the expression to
      Code:
      =DCount("[ChkAmt]","tblChecks","[ChkAmt]>50")
      and
      Code:
      =DCount("[ChkAmt]","tblChecks","[ChkAmt]">"50")
      . In both instances the result was #Error. Does the solution have anything to do with whether or not I'm using brackets and quotes appropriately?.

      I would have responded sooner, but was searching the site for issues the same as or similar to mine.
      Last edited by zmbd; Jun 20 '13, 01:15 PM. Reason: [z{placed required code tags}]

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You have an extra double quote that popped out of nowhere. It wasn't in your original code.

        Comment

        • Tempo
          New Member
          • Jun 2011
          • 10

          #5
          I was experimenting with different bracket and quote positions, but none of my combinations appear to work. Here's the last failed attempt:
          Code:
          =DCount("[ChkAmt]","tblChecks","[ChkAmt]>50")
          Last edited by zmbd; Jun 20 '13, 01:16 PM. Reason: [z{placed required code tags}]

          Comment

          • Mihail
            Contributor
            • Apr 2011
            • 759

            #6
            As far as I know, NO brackets are necessary in DCount function:
            Code:
            =DCount("ChkAmt","tblChecks","ChkAmt>50")
            Last edited by zmbd; Jun 20 '13, 01:16 PM. Reason: [z{placed required code tags}]

            Comment

            • Mihail
              Contributor
              • Apr 2011
              • 759

              #7
              Again, as far as I know, this structure is available for all D functions.

              Comment

              • Tempo
                New Member
                • Jun 2011
                • 10

                #8
                You're absolutely correct, Mihail, brackets are necessary when numbers, spaces, or some other character is used in Object and Control names.

                When you included the expression I sent I could clearly see my mistake. A small, but critical one at that. Are you ready? The domain is "tblCheck" not "tblChecks" .

                There you are...problem resolved. Much thanks goes out to you and "Hats Off" to Rabbit as well. You guys are Great!

                Comment

                Working...