Sum IF in Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tee GEE

    Sum IF in Access

    Is there a SumIF function in Access? I have to SUM a duration of time,
    but only if a logical Yes/No check box is TRUE. I am working with the
    expression builder and a Text Box. Thanks for the help.

    Forgive me...I'm a beginner programmer with expert expectations.

    *** Sent via Developersdex http://www.developersdex.com ***
  • eal1@nyu.edu

    #2
    Re: Sum IF in Access

    Hi -
    You need to nest your IF and SUM functions, like so:
    IF(y/n field=y,SUM(val ue1,value2)null )
    This means if y/n criteria is true, the sum of value1 and value2
    appears, if not then a null (blank) value appears.
    Eddie

    Tee GEE wrote:
    Is there a SumIF function in Access? I have to SUM a duration of time,
    but only if a logical Yes/No check box is TRUE. I am working with the
    expression builder and a Text Box. Thanks for the help.
    >
    Forgive me...I'm a beginner programmer with expert expectations.
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • gumby

      #3
      Re: Sum IF in Access

      =Sum(IIf([OK]=True,[Date],0))

      This is going to Sum the data. If you want to sum the duration such as
      from 8am to 4pm then you might look at the TimeValue function.


      Returns one of two parts, depending on the evaluation of an expression.

      Syntax

      IIf(expr, truepart, falsepart)

      The IIf function syntax has these named arguments:

      Part Description
      expr Required. Expression you want to evaluate.
      truepart Required. Value or expression returned if expr is True.
      falsepart Required. Value or expression returned if expr is False.



      Remarks

      IIf always evaluates both truepart and falsepart, even though it
      returns only one of them. Because of this, you should watch for
      undesirable side effects. For example, if evaluating falsepart results
      in a division by zero error, an error occurs even if expr is True.



      Tee GEE wrote:
      Is there a SumIF function in Access? I have to SUM a duration of time,
      but only if a logical Yes/No check box is TRUE. I am working with the
      expression builder and a Text Box. Thanks for the help.
      >
      Forgive me...I'm a beginner programmer with expert expectations.
      >
      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • gumby

        #4
        Re: Sum IF in Access

        =Sum(IIf([Your logical yes/no field]=True,[Your duration of time
        field],0))

        This is going to Sum the data. If you want to sum the duration such as
        from 8am to 4pm then you might look at the TimeValue function.


        Returns one of two parts, depending on the evaluation of an expression.



        Syntax


        IIf(expr, truepart, falsepart)


        The IIf function syntax has these named arguments:


        Part Description
        expr Required. Expression you want to evaluate.
        truepart Required. Value or expression returned if expr is True.
        falsepart Required. Value or expression returned if expr is False.


        Remarks


        IIf always evaluates both truepart and falsepart, even though it
        returns only one of them. Because of this, you should watch for
        undesirable side effects. For example, if evaluating falsepart results
        in a division by zero error, an error occurs even if expr is True.


        Tee GEE wrote:
        Is there a SumIF function in Access? I have to SUM a duration of time,
        but only if a logical Yes/No check box is TRUE. I am working with the
        expression builder and a Text Box. Thanks for the help.
        >
        Forgive me...I'm a beginner programmer with expert expectations.
        >
        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • chris.nebinger@gmail.com

          #5
          Re: Sum IF in Access

          And, another way would be to use the DSUM function:

          Dsum("[Timefield]","TableName"," CheckField=True ")


          Chris Nebinger


          Tee GEE wrote:
          Is there a SumIF function in Access? I have to SUM a duration of time,
          but only if a logical Yes/No check box is TRUE. I am working with the
          expression builder and a Text Box. Thanks for the help.
          >
          Forgive me...I'm a beginner programmer with expert expectations.
          >
          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          Working...