Results 1 to 5 of 5
  1. #1
    broodmdh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    7

    Calculated field based on a query

    We have several fields that should contain calculated dates, based on a value in that table and dates stored in another table. Is it possible to use a query to update these fields when the value is updated or dates are added? A single user will have one or more date ranges in the secondary table, and the sum of those ranges are applied against the value in the originating table to give the results for the calculated fields.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    I suspect Yes but why? Just build query and do the calcs in query. Not sure what you mean by 'sum' of date ranges. How is a date range summed? Really need better understanding of data structure to advise.
    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
    broodmdh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    7
    The date ranges indicate terms of service. Most people will only have one (with no end date if a current employee) but some could have several. The calculated dates indicate milestones (anniversary dates etc). Can I set a trigger that gets fired when a date range is added to the table? Ideally the dates will update without direct human interaction. Do I have to tie a query to a form? I'm not very familiar with the Access model, so please forgive any ignorant questions.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Yes, entering data is an event and events run code. Do not have to tie query to form but probably best. Users should not work directly with tables and queries.

    Conventional wisdom is to not save calculated data - calculate when needed.
    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
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    if you need to store the prior dates - then you have Query 1 that does your calculation and append it to the table. But if you are over writing the prior data - then you should follow J7's advice and abandon fields in the table and instead rely on display fields (unbound) in forms/reports. For instance my bound field can be 1/1/2016 and the displaying fields can auto plus/minus days on that date and they will change immediately upon a change of the bound date field. Look up the DateAdd function for the syntax to put into the unbound field.

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

Similar Threads

  1. Replies: 10
    Last Post: 06-10-2015, 08:16 AM
  2. Replies: 1
    Last Post: 01-31-2015, 11:07 AM
  3. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  4. Replies: 2
    Last Post: 05-23-2014, 08:35 PM
  5. Replies: 6
    Last Post: 06-08-2011, 05:00 PM

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