Results 1 to 3 of 3
  1. #1
    jmbreland is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    3

    Automatically record current date and time when a specific field is modified

    I would like for my Access 2007 database to automatically record the date/time when the data in a SPECIFIC field is modified (not when any data in the record changes).



    Here is a simplified explanation of my scenario. This database keeps track of cases in my office. A data entry form named "[Case Status Update]" feeds a table named "Cases." The form includes text boxes that correspond to the fields in the table. Three of these are: "Case_Notes," "Case_Status," and "Date_Status_Change."

    I would like for the "Date_Status_Change" field to automatically reflect the current date/time whenever the data in the "Case_Status" field changes. I do not want the date/time to change when information in the "Case_Notes" field is modified.


    The following code will enter the date/time for a change anywhere in the record:

    Private
    Sub Form_BeforeUpdate(Cancel As Integer)

    Me![Date_Status_Change].Value = Now()
    End Sub

    But I want to limit it so that it dates changes ONLY in the “Case_Status” field. What code would accomplish this?



  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Put the code in the After Update event of the Case_Status field.

  3. #3
    jmbreland is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    3
    Got it. This works insofar as I decided I only want a date entry when the status changes to "complete."

    Private Sub Status_AfterUpdate()
    If Me.Case_Status = "Complete" Then
    Me.Date_Status_Change = Now()
    End If
    End Sub

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

Similar Threads

  1. Enter current date and time into subform field
    By tonybrecko in forum Forms
    Replies: 8
    Last Post: 06-16-2013, 09:58 PM
  2. Replies: 4
    Last Post: 03-06-2013, 02:32 PM
  3. Replies: 6
    Last Post: 12-11-2012, 09:40 PM
  4. Replies: 2
    Last Post: 08-02-2012, 01:47 PM
  5. Replies: 1
    Last Post: 09-20-2007, 02:56 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