Results 1 to 5 of 5
  1. #1
    scratchmb is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    6

    Running Total Based on a Date in a field

    I have a database that tracks consecutive miles a driver has driven without an accident. I would like for the running total to reset to 0 whenever the driver has an accident but don't want to lose historic data in case it needs to be referenced.



    Anyone have any ideas.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Calculated fields should never reside on a table. Your "consecutive miles" is a calculated field, therefore will not exist but will be calculated every time is is needed (forms, reports, etc.). The values that will be kept on the table will be those that are required to do the calculation, i.e. date of last accident, miles driven by date. Your calculation will be done using those two fields stored on tables.

    You could also have a table that stored accident data which would contain the historical information, although this is not required. It could store the number of miles from last accident to this accident, which would never change and would never need to be recalculated.

  3. #3
    scratchmb is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    6

    calculated field based on a date

    Ok, you'll have to excuse me, I know enough to get myself in trouble. I understand what your saying, but can't get the calculation to work since [dateoflastaccident]

    I have a table with miles per week [miles] [payperiod] and i have a table with accidents by date [dateofaccident] what would the expression look like for the calculated field.

    thanks for your last post and like I said i know just enough to get in trouble.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Firstly, don't apologize - we all started somewhere.

    It is a difficult calculation because you don't carry the information that is required. Here are the steps you need to do - get it straight in your mind before trying to get the computer to do it:

    1) Analyze the calculation and write it down in words, e.g. number of accident-free miles = number of miles covered since last accident
    2) figure out where each bit of the equation is going to come from
    a) number of miles covered
    b) date of last accident
    The last one is easy as it is a field stored on a table
    The number of miles covered is the hard one as you rather mixing apples and oranges here. Say they have an accident on Tuesday the 15th. You know they covered 500 miles in the pay period (11th thru 17th). Let's say they had a to-date total of 1,000 miles. Now you, the designer, need to work out how to calculate it - is the answer going to be 1,000 miles (as of the end of the previous pay period) or is it going to be 1,500 (the end of the following pay period) or some other calculation such as 500 miles divided by 7 days multiplied by 4 days (til Tuesday).

    Once you have written the calculation out and know exactly what you want, then - and only then - can it be translated into Access.

  5. #5
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Forgot to mention - date of last accident could be blank, you will need to have another date for those cases. Date of hire?

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

Similar Threads

  1. Replies: 1
    Last Post: 01-29-2012, 01:06 PM
  2. Running total
    By lololthis in forum Queries
    Replies: 5
    Last Post: 06-21-2011, 04:14 PM
  3. Replies: 1
    Last Post: 03-05-2011, 03:05 PM
  4. Creating field based an another field's total
    By yashysmashy in forum Queries
    Replies: 0
    Last Post: 09-02-2009, 03:48 AM
  5. Total based on Formula based on field value
    By cjbuechler in forum Reports
    Replies: 15
    Last Post: 07-10-2009, 09:56 AM

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