Results 1 to 7 of 7
  1. #1
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43

    Sum fields in subform if not Null

    Hello ,
    I have a form with a textbox where user enters date , one button that requeries a subform and one SumTextbox that shows the sum of one field of subform.


    When the user enters a date , that is not on a subform , subform returns blank , and on the SumTextbox I get #Error.

    How can I input criteria ,so that when the field is blank ,my ResultTextbox shows 0?

    By now I have tried :
    Code:
    = IIf ( IsNull([FieldName])  ; 0; sum( [FieldName] ))
    and this : http://allenbrowne.com/RecordCountError.html
    but this doesn't work

  2. #2
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Try

    NZ(Sum ( [FieldName] ),0)

    Untested

    FieldName must be a Field from the RecordSource of the SubForm.

    If I am wrong search Help for the correct syntax.

  3. #3
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    Code:
    NZ(Sum ( [FieldName] ),0)
    This didn't work either...

    Someone please help

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Did you go to help and check the syntax.?

    Where is Field Name located?

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    Are you Counting records or SUMming Values in a Field?

  6. #6
    atom is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    43
    I use Sum in subform,on mainform ResultTextbox has Controlsource like that:

    Code:
    =[subform].[Form]![SumFieldName]
    where SumFieldName is the Name of textbox in subform

  7. #7
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    This has been tested.

    Sum ( [FieldName] )

    What result do you get.

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

Similar Threads

  1. How to Check If Two Fields are Null?
    By alpinegroove in forum Programming
    Replies: 5
    Last Post: 01-04-2012, 01:41 PM
  2. Is Not Null...Multiple fields
    By msk7777 in forum Access
    Replies: 13
    Last Post: 11-17-2011, 02:52 PM
  3. Query Not Returning Null Fields
    By mgmirvine in forum Queries
    Replies: 2
    Last Post: 10-28-2011, 06:15 PM
  4. Combine two fields, Null fields involved
    By yes sir in forum Access
    Replies: 9
    Last Post: 10-03-2010, 09:20 AM
  5. Replies: 5
    Last Post: 03-20-2010, 08:30 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