Is there an easy way to find out the last time a record was changed in a table and show this value in a simple query?<br><br>Thanks in advance!<br><br>Greetings,<br><br><br>Dirk<br><br><br><A HREF="mailto:dirk.news@yucom.be">dirk.news@yucom.be</A>
Depends on your definition of simple! ;-)<br><br>Access does not automatically time/date stamp records when they are changed. You can "easily" set this up by forcing all changes to be made through forms. You would add a field to any table that you want to audit, call it LastChanged. Then you would write code behind the form to post the current date and time to the LastChanged field whenever a field is changed. You could also capture the login of the person who changed it, but that is a bit more complicated.<br><br>Hope this helps. <p>Kathryn<br><a href=mailto: > </a><br><a href= > </a><br>
I wrote a FAQ on this you might find helpful in the "Access: General Discussion" forum on this site. I think it is titled something like "getting user lgoin and date" and it tells how to capture both when a record is added or updated.
I didn't write this but it works; it needs a table to store the log:
==========================================================
Option Compare Database 'Use database order for string comparisons
Option Explicit
Function ahtLog(strTableName As String, varPK As Variant, intAction As Integer) As Integer
' Log a user action in the log table
On Error GoTo ahtLog_Err
Dim db As Database
Dim rstLog As Recordset
Set db = CurrentDb()
Set rstLog = db.OpenRecordset("ChangeLogging", dbOpenDynaset, dbAppendOnly)
With rstLog
.AddNew
![UserName] = fUserNTIdent 'modules to get the ID are readily available. Let me know if you cannot find one.
![TableName] = strTableName
![RecordPK] = varPK
![ActionDate] = Now
![Action] = intAction
rstLog.Update
End With
I was looking for a solution to a similar problem and came across this.
Is there an any way, last update date for record can appear directly in a field within the table without having to use a form. Or in other words, could we not have a code directly add date to a table field as soon as a record is saved in that table.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.