Results 1 to 2 of 2
  1. #1
    Craftsman55 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2019
    Posts
    1

    Help, sum 2 field values to 3rd field


    Please help! I have been trying to build an expression in Access Professional 2013 with no luck. I have an Asset Maintenance Sub-form added to my Asset Form. On the Maintenance Sub-form I have 3 fields: Service cost, parts cost and Total cost. I would like to do is when I enter an amount in Service cost &/or Parts cost have it automatically insert the total into Total cost. I have entered this expression: [Total cost] = ([Service cost] + [Parts cost]) in various forms and nothing works.

  2. #2
    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
    Entered it where..in what event?

    First, you have to understand that Anything + Null (an empty Textbox) = Null. To have Service Cost or Parts Cost entered in the Total Cost Textbox, you need to allow for one of them being empty...so, in VBA in an event (in the AfterUpdate event of the Service cost and Parts cost Controls, you'd use

    [Total cost] = (Nz([Service cost],0)) + (Nz([Parts cost], 0))

    which converts a Null value to Zero.

    Or, in the Control Source Property (in Properties - Data) for [Total cost] you'd use

    = (Nz([Service cost],0)) + (Nz([Parts cost], 0))

    The latter suggestion is probably the one you should be using.

    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. Replies: 1
    Last Post: 12-10-2017, 01:47 AM
  2. Replies: 2
    Last Post: 05-17-2017, 06:17 AM
  3. Replies: 16
    Last Post: 01-05-2016, 04:13 PM
  4. Replies: 18
    Last Post: 03-26-2015, 07:26 AM
  5. Replies: 1
    Last Post: 02-19-2014, 11:07 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