Results 1 to 3 of 3
  1. #1
    Pyeman is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2021
    Posts
    4

    Calculated field using Expression Builder


    I'm new to Access. I am trying to develop a golf scoring program whereby I can track participants earnings and report those earnings for each discrete tournament. I created a table with each participants name and additional fields with additional data. In addition I created individual fields for all the potential money prizes (such as low gross, KP, Skin, etc) a participant could win in any given tournament. I have entered data into these fields. I want a final field that adds these money fields together to generate a total for each individual player. I tried creating a calculated field in Expression Builder called "Total earnings" by selecting those relevant fields. It successfully generated a total for the first player but not the others. What am I doing wrong??

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Most likely one or more fields in the expression is Null. Arithmetic with Null results in Null. Either normalize table structure so each prize won is a record in a related dependent table or handle possibility of Null with

    IIf(IsNull(KP),0,KP) + ...

    or

    Nz(Low) + Nz(KP) + Nz(Skin)

    Unfortunately, Nz() is not available to table calculated field. Do this calc in query or textbox.
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    you have taken an excel approach to your database which is not the way for databases. And using calculated fields in tables is a bad idea, just because you can doesn't mean you should

    from your brief description I can see the need of at least 4 tables, possibly more - participants, tournaments, prizes linked to tournaments and a linking table between participants and tournament prizes

    Not trying to put you off, but if you want to do it the way you have described, suggest use Excel which works with those methods

    As regards your question, would need to see what you have used in your calculation, if it works for one player it should work for all of them. Best guess would be your data contains nulls so you would need to use an iif statement around an isnull function

    ....+iif(isnull(myfield),0,myfield)+.....

    a properly constructed db would do this automatically

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

Similar Threads

  1. Replies: 12
    Last Post: 07-06-2017, 11:43 AM
  2. Replies: 4
    Last Post: 05-03-2016, 01:51 PM
  3. Replies: 1
    Last Post: 07-24-2014, 08:35 PM
  4. Replies: 1
    Last Post: 05-09-2013, 07:54 PM
  5. Replies: 2
    Last Post: 11-20-2012, 03:21 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