Full Version: Modified Date
UtterAccess Discussion Forums > Microsoft® Access > Access Date + Time
EOttenheimer
In my form, the initial entry date and user automatically are added to each form. I am also trying to have modified date and modified by field added that automatically fill in anytime a record is changed. I cannot get this to show up. Any thoughts?
Paul_Bricker
Get it to show up where? You can use the On Dirty event, the AfterUpdate Event, the OldValue method. Really, it would help to have a little more info.

Paul
EOttenheimer
I have attached a print screen of the form I am working with. I want the modified date and name of the user to show the next time the record is opened. If I am not being specific enough, please let me know what other information you need.
EOttenheimer
I could not attach the print screen, so all I can tell you is that I am trying to have a modified date and user appear after changes are made in a record.
Paul_Bricker
Well, generally speaking you would create a table to hold the modified data. You might have 3 fields

FieldName......DateModified......txtOldValue

then in a sub, you could have this code.
CODE
Sub captureChange()
Dim rst As DAO.Recordset
Dim fldName As String
Dim ctl As Control
Set rst = CurrentDb.OpenRecordset("tblModified", dbOpenDynaset)
If Me.NewRecord Then
   Exit Sub
End If
If Me.Dirty Then
   For Each ctl In Me.Controls
     If ctl.ControlType = acTextBox Then

        rst.AddNew
        rst!FieldName = ctl.Name
        rst!DateMod = Now()
        rst!txtOldValue = ctl.OldValue
        rst.Update
     End If
  Next
End If
End Sub


Then you would call this code from the AfterUpdate event for each control you want to keep track of changes in.

Paul
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.