Results 1 to 6 of 6
  1. #1
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30

    I cannot find the typo...please help wih this Nz statement

    I am adding 4 fields together that contain either 0 or a currency value...I want to show a "0" in the field if the value is Null or ""...Nz is nested in each of the 4 fields that are being adding so each field is set to "0" if there are any blanks or nulls.


    I have included the statement for one of the other fields where the Nz statement works great...I can not get the "sum of the other fields" to work Please Help!

    Working statement in one of the fields being added
    Code:
    =IIf(Nz([sage_sd_schlrshp],"")="","0","& [sage_sd_schlrshp]")
    this is the "sum of the other fields" statement
    Code:
    = IIf(Nz(=([sage_sd_schlrshp]+[sage_vf_schlrshp]+[vf_private_donor]+[Other]),"")="","0",=([sage_sd_schlrshp]+ [sage_vf_schlrshp]+ [vf_private_donor]+[Other]))
    I have even tried this statement
    Code:
    = IIf(Nz(=([sage_sd_schlrshp]+[sage_vf_schlrshp]+[vf_private_donor]+[Other]),"")="","0","& =([sage_sd_schlrshp]+ [sage_vf_schlrshp]+ [vf_private_donor]+[Other])")
    Last edited by lynthel; 04-25-2014 at 10:31 AM. Reason: working with other code

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Why do you have those 2 extra = signs?

    Both expressions reference the same field, but neither expression contributes to the result of the other.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    Quote Originally Posted by June7 View Post
    Why do you have those 2 extra = signs?

    Both expressions reference the same field, but neither expression contributes to the result of the other.
    Taking out the extra "=" did the trick...as for the statement...I want Access to either return the sum of the other fields or return a 0....when I tried just adding the other fields, I would get a #name? error showing on the form. I think it might have had to do with setting the other fields to "0" (a string) if no value was put in those fields. Does Access have a "Convert.ToInt" function?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    CInt, CDbl, CLng

    However, those all fail on either empty string or null.

    Val() will convert "" to 0 but fails on null.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    Thank you very much June7...now on to the next question (which I am sure I will see and look forward to your help)

  6. #6
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You don't really need the IIf part - the Nz is sort of an abbreviated IIf in itself. All you need is to add the 4 fields, each within its own Nz:

    =Nz([sage_sd_schlrshp],0) + nz([sage_vf_schlrshp],0) + nz([vf_private_donor],0) + nz([Other],0)

    Set the default value for each of these fields to 0 - that way you know the Nz will work. When entering data into a form textbox, all-blanks is treated the same as no data - Null.

    HTH

    John

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

Similar Threads

  1. To find out the first 2 max
    By murali in forum Access
    Replies: 1
    Last Post: 04-22-2014, 03:59 PM
  2. Find first won't find
    By lawdy in forum Programming
    Replies: 7
    Last Post: 12-15-2013, 02:00 PM
  3. Find
    By sergran in forum Programming
    Replies: 2
    Last Post: 10-08-2013, 01:02 AM
  4. I can't find the bug. Please help
    By sharVyn in forum Programming
    Replies: 5
    Last Post: 08-27-2012, 03:39 PM
  5. Find a SUM
    By jcsports31 in forum Access
    Replies: 8
    Last Post: 09-14-2010, 10:07 AM

Tags for this Thread

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