Results 1 to 4 of 4
  1. #1
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141

    Sum Not working?

    I have


    Code:
    Sum(IIf(IsNull([SalesOrder]) And [Approved]=True,1,0))
    I would like it to count all records that do NOT have anything in [SalesOrder] And is [Approved] - this should be returning a number (there are some records that mtch the criteria) - But it is returning 0

    Is there something I am missing?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    I would create a calculated field in the forms record source query with something like:
    Code:
    Cal: IIf(IsNull([SalesOrder]) And [Approved]=True,1,0)
    Then add a textbox to your form bound to the calculated field (Cal) and then do a simple sum of that in the Header or Footer
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It could also be that your field isn't Null. Try

    Sum(IIf(Nz([SalesOrder], "") = "" And [Approved]=True,1,0))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    crimedog is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2013
    Posts
    141
    Thanks guys - tried changing the formula and it worked.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-27-2020, 09:49 AM
  2. Replies: 2
    Last Post: 05-14-2017, 10:07 AM
  3. Working query stops working after importing
    By Abacus1234 in forum Import/Export Data
    Replies: 3
    Last Post: 10-25-2015, 09:12 PM
  4. Replies: 1
    Last Post: 12-27-2014, 12:38 PM
  5. Replies: 3
    Last Post: 01-29-2013, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums