Results 1 to 2 of 2
  1. #1
    AnneForumer is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    20

    Use a calculated field to update multiple fields

    Is there a way to calculate a value once and use it to update multiple fields?

    Update Bio_data
    set height = IIF(Left([age],3) < 20, 30,IIF([age],3) > 20, 60, 0))
    weight = IIF(Left([age],3) < 20, 12,IIF([age],3) > 20, 50, 0))

    The <computed value> is computed using a long formula using values in other fields. I'd like to not have to write out the long formula multiple times. In this example, I'd like to compute Left([age],3) once and reuse it at multiple places. This is just a representative calculation; it can be even longer.



    I welcome alternative solutions, however I'd like to know if what I'm asking for is do-able.

    Thank you.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a function in a global module which does the calculation from the parameters that you pass it. You can then use it anywhere in the system.

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

Similar Threads

  1. Update query with calculated fields?
    By shaunacol in forum Queries
    Replies: 9
    Last Post: 07-09-2015, 01:32 PM
  2. Replies: 5
    Last Post: 04-05-2013, 12:02 PM
  3. Calculated fields going blank after update
    By Monterey_Manzer in forum Forms
    Replies: 3
    Last Post: 10-08-2012, 03:21 PM
  4. Replies: 15
    Last Post: 10-14-2010, 12:22 PM
  5. Replies: 1
    Last Post: 02-03-2010, 09:17 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