Results 1 to 8 of 8
  1. #1
    dictionary101 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    4

    Question Consider an empty field $0.00 in a query in order to provide a result in an equation

    I am working on a project funding query. I've managed to subtotal the invoices posted per project and subtract that amount from the total amount allocated for the project.
    Code:
    REMAINING Funding Available: ([qry_Funding totals AND Invoice totals].[SumOf$Funding]-[Sum Of InvoiceAmount])
    The result shows me the amount remaining for any projects from which an invoice has been posted and funds subtracted. Exactly what I want to see.

    However, not all projects have had work done yet, so there aren't invoice amounts to subtract. How can I write the equation so that those projects show $0.00 as the invoiced amount and the full allocated amount remaining?



    Thank you in advance for your help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Arithmetic with null results in null. Handle null: Nz([Sum Of InvoiceAmount],0)
    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
    dictionary101 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    4
    I've never seen Nz before. Where does that fit in the equation: REMAINING Funding Available: ([qry_Funding totals AND Invoice totals].[SumOf$Funding]-[Sum Of InvoiceAmount])?

    I tried a couple of places I thought might work and, depending on where I put it, I got error messages about commas or parentheses being wrong.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    It fits as shown.

    REMAINING Funding Available: [qry_Funding totals AND Invoice totals].[SumOf$Funding] - Nz([Sum Of InvoiceAmount],0)

    Post the entire SQL statement for analysis.
    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
    dictionary101 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    4
    YES!!!!! You ROCK!!!! Thank you very, very, very much!!!

    I think I omitted the spaces around the subtraction symbol. Thank you again!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Those spaces are not important. Would not make any difference. Access might even throw them in if you forget.

    Glad it's working.
    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.

  7. #7
    dictionary101 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    4
    Hmmm . . . then I don't know what I did when I typed it myself. When I copied the equation from your message and pasted it over what I had it worked! I'm doing the happy dance here.

    Thanks again.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Might have had some misplaced and/or unpaired parens.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-15-2013, 02:29 AM
  2. Catch empty search result
    By octsim in forum Programming
    Replies: 5
    Last Post: 12-02-2013, 02:23 PM
  3. Replies: 4
    Last Post: 10-29-2012, 02:20 PM
  4. When a query result is empty.....
    By khanson in forum Queries
    Replies: 3
    Last Post: 08-01-2011, 09:12 PM
  5. Controls go blank on empty query result
    By kevdfisch in forum Programming
    Replies: 4
    Last Post: 08-25-2009, 08: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