DCount function returning zero records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhonda6373
    New Member
    • Mar 2010
    • 35

    #1

    DCount function returning zero records

    Hello,

    I am trying to count a field ID from Completed (the table name) where the values in a text box (txtFinal) on a form = RPR*. It is coming up with zero records when there are several. Do I have something wrong with the syntax?
    Code:
    =DCount("[ID]","Completed","[txtFinal] = 'RPR*'")
    The count I want to return is the amount of records on the subform where txtFinal = "RPR*".

    I tried changing to this:
    Code:
    =DCount("[ID]","Completed","[Final] = 'RPR-RPR & RTN'")
    It is no longer giving me zero. It is now giving me the total number of records in the Table where Final = 'RPR-RPR & RTN', not the total number of records on the subform.

    Thanks in advance!

    Rhonda

    Thanks Neopa! Sorry about not putting the code tags in. I still have a question however. How can I count the number of records where a match is found in the subform instead of the table? It is now counting all matches in the table and not the subform.
    Last edited by NeoPa; Jun 14 '15, 10:09 PM. Reason: Added code tags and merged the posts together.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Originally posted by Rhonda
    Rhonda:
    Do I have something wrong with the syntax?
    Indeed you do Rhonda. You're trying to treat a wildcard-type filter as you would a direct match. The syntax for matching a wildcard is :
    Code:
    [X] Like 'blah'
    Examples of Wildcard Characters may prove useful.

    Comment

    Working...