Results 1 to 4 of 4
  1. #1
    Luke is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    72

    Question Sum Function Problems

    I have created a query that includes "EntityName", "1st Investment", and "2nd Investment". I created an expression using the Builder and called it "Total Invested". My Expression is TotalInvested: ([1stInvestment]+[2ndInvestment]). However when I run the query my Expression only shows a value when there are both a 1st and 2nd investment value. I want the expression to show the total investment even when there's only a 1st investment! For example, if my 1st investment is $20 and my 2nd Investment is $40, my expression will show the total invested to be $60. That's what I want. But when my 1st investment is $20 and there isn't a 2nd investment value ($0), my expression doesn't show anything when I run it in the query. Do you know what function or expression I could use to solve this problem?
    Thanks.



    -Luke

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You need to incorporate the NZ function into your expression. The NZ function allows Access to process a null record. Here is a link on how to employ the NZ function and apply it to your expression.

    http://www.techonthenet.com/access/f...dvanced/nz.php

    You will want to make your expression:

    TotalInvested: NZ(1stInvestment, 0)+ NZ(2ndInvestment,0)

    Alan

  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
    Wrap each field in the Nz() function:

    Nz(FieldName, 0)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Luke is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    72
    That worked perfectly thanks a ton

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

Similar Threads

  1. Replies: 2
    Last Post: 05-16-2011, 04:11 PM
  2. problems please help
    By stryder09 in forum Access
    Replies: 1
    Last Post: 02-15-2011, 02:24 PM
  3. Several problems
    By Bergh in forum Access
    Replies: 1
    Last Post: 05-30-2010, 03:56 AM
  4. OLE problems how to fix
    By miziri in forum Access
    Replies: 7
    Last Post: 04-29-2010, 06:18 AM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 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