Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Counting a Field if it has a Result (2000)

    Hi:

    I need a querry function to calculate whether a field has a date entered in it or not. We are trying to count all the "replies" we receive and we note the replies by entering the date received in a field called "date confirmed". Now I want to look back at all the records and count all the ones that have replied so far. I tried to do an IF/THEN statement in the querry calculation but I couldn't do it.

    Any ideas?
    Thanks,
    Craig

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Counting a Field if it has a Result (2000)

    You can use an expression like this in a totals query:

    RepliedCount: Abs(Sum(Not IsNull([Date Confirmed])))

    IsNull([DateConfirmed]) is True if Date Confirmed has not been filled in yet, False otherwise.
    Not IsNull([DateConfirmed]) is True if Date Confirmed has already been filled in, False otherwise.
    In Access, True = -1 and False = 0, so in the Sum function, each filled in date counts as -1, i.e. the Sum function counts minus the number of filled in dates.
    The Abs function removes the minus.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,430
    Thanks
    1
    Thanked 33 Times in 33 Posts

    Re: Counting a Field if it has a Result (2000)

    I believe this can be done simply by using a totals query, that includes doing a Count on that date field. Count only counts non-null entries.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Counting a Field if it has a Result (2000)

    Yes, that is easier than the solution I proposed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •