Results 1 to 6 of 6
  1. #1
    drblanston is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    2

    Trapping for EOF in Control Source

    I currently have a subform that has a sum() text field which sums up all the payments of the records listed. The control source of that text field looks like this:

    =Sum([pymt_Amount])

    Its a pretty simple calculated field.

    However, I need to trap for End of File (EOF). In other words, if there are no records, I want this field to be 0 (zero).

    Is there a way to put an IIF statement that says something like =IIF (EOF syntax, 0, Sum([pymt_Amount]))

    The EOF syntax is what I am looking for.



    any clues?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Don't think can detect EOF in ControlSource expression.

    Try:

    =Nz(Sum([pymt_Amount]),0)

    or

    =IIf(Count(*)=0, 0, Sum([pymt_Amount]))
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    All you need to do is to change

    =Sum([pymt_Amount])

    to

    =Nz(Sum([pymt_Amount]),0)

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Ouch! Didn't bump you too hard at the finish line, did I, June?
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    drblanston is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    2
    Gracias.... the Nz(Sum([pymt_Amount]),0) works well... Puts the Zero in the field. Thanks again

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help!

    Good luck with your project!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Control Source Error ?
    By bellevue in forum Forms
    Replies: 8
    Last Post: 06-02-2012, 12:47 PM
  2. Help with Control Source
    By love2waltz in forum Access
    Replies: 1
    Last Post: 05-18-2012, 01:09 PM
  3. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  4. control source
    By nashr1928 in forum Forms
    Replies: 5
    Last Post: 03-12-2011, 09:31 PM
  5. Control Source
    By sarah54 in forum Access
    Replies: 1
    Last Post: 03-07-2011, 09:00 PM

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