Results 1 to 3 of 3
  1. #1
    rikesh is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    5

    Question Storing a value with associated time

    Hello all,

    I am a beginner so please go easy on me!



    Situation

    I have a database which contains a field 'status'. This status takes a numerical value (1, 2, 3, etc...). Everything works great.

    What I want is to monitor the length of time a field spends on particular status. Specifically, I want to record the length of time that the record spends with a status value of 3. So if the record has its status changed to 3, the system 'starts the clock' and once the status changes away from 3, the system 'stops the clock'. This must also continue if the status subsequently returns to 3 at a later date (for the same record) and cumulatively produce the total amount of time that the record spent on status 3.

    Practical example
    March 19th: Record is set to status 3 (for the first time)
    March 21st: Record is set to status 1
    March 25th: Record is set to status 3 (again)
    March 27th: Record is set to status 2

    In this scenario, I want visibility that the record has spent four days on status 3 altogether. I don't need exact times (nearest day will do). Ideally the system will only count working days (although this is not a must-have).

    Could anyone suggest a solution for what I am looking for? Many thanks in advance, I really appreciate your help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Need another table to store records of this data.

    Run code in the BeforeUpdate event of Status combobox to save record ID, date/time, and status code.

    If OldValue and NewValue are not the same then if OldValue or NewValue is 3 save StatusChange record.

    Something like:

    If Me.OldValue <> Me.NewValue Then
    If Me.OldValue = 3 or Me.NewValue = 3 Then
    CurrentDb.Execute "INSERT INTO StatusChange(RecID, ChangeDate, Status) VALUES(" & Me.ID, & ", #" & Now() & "#, " & Me.cmbStatus & ")"
    End If
    End If
    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
    rikesh is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    5
    Quote Originally Posted by June7 View Post
    Need another table to store records of this data.

    Run code in the BeforeUpdate event of Status combobox to save record ID, date/time, and status code.

    If OldValue and NewValue are not the same then if OldValue or NewValue is 3 save StatusChange record.

    Something like:

    If Me.OldValue <> Me.NewValue Then
    If Me.OldValue = 3 or Me.NewValue = 3 Then
    CurrentDb.Execute "INSERT INTO StatusChange(RecID, ChangeDate, Status) VALUES(" & Me.ID, & ", #" & Now() & "#, " & Me.cmbStatus & ")"
    End If
    End If
    Thank you for your reply. This looks like exactly what I am looking for.

    I will be using this sometime next week - if any problems I'll post back haha, but thanks for your help I appreciate it.

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

Similar Threads

  1. Replies: 42
    Last Post: 03-01-2013, 06:58 AM
  2. Storing Elapsed Time in a Field
    By andybuck86 in forum Access
    Replies: 1
    Last Post: 10-08-2011, 05:07 AM
  3. entering one value but storing another
    By greatfallz in forum Forms
    Replies: 1
    Last Post: 06-09-2011, 07:23 AM
  4. Help with end balance storing
    By Hulk in forum Database Design
    Replies: 6
    Last Post: 03-24-2011, 04:21 AM
  5. storing and printing on a pdf
    By jlm722 in forum Reports
    Replies: 4
    Last Post: 10-27-2009, 02:48 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