Good Day All,Would be grateful to find code that can enter the date and time of any update that is done to a table, if such a thing is practical.Thanks in advance.
Good Day All,Would be grateful to find code that can enter the date and time of any update that is done to a table, if such a thing is practical.Thanks in advance.
i have a log table to write to for events like this.
usage:
Post2Log "tEmployees", "update","user changed data", "Phone#", txtPhone
Code:Public Sub Post2Log(pvEvent, pvSubEvent, pvDescr, ByVal pvField, byval pvVal ) dim vUser vUser = Environ("Username") sSql = "INSERT INTO tLog ([Event],[subEvent],[USER],[EntryDate],[FieldName],[NewVal] ) values ('" & pvEvent & "','" & pvSubEvent & "','" & vUser & "',#" & Now() & "#,'" & pvField & "','" & pvNew & "',)" DoCmd.RunSQL sSql end sub
if you are looking for changes to tables from direct interaction, queries, forms etc then check out this use of data macros post 21 for sample.
Thanks.
I am seeking something simpler and similar to the automatic date created for a new record. This is done at the Table Design View Level.
And this is not with reference to the update of any specific field. Once any field is altered in the record an updated date/time is recorded.
But your solution is something that spurs my interest because that is more specific.
I used to have this in my relevant forms
However that just shows the last person to update, which was all I needed.
Code:Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.NewRecord Then Me.CreatedDate = Now() Me.CreatedBy = Environ("username") Else Me.AmendedDate = Now() Me.AmendedBy = Environ("username") End If End Sub
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Thanks.
This link gives the solution:
Store the date and time when a record is modified - Access (microsoft.com)
Isn't that exactly what I was doing, just with VBA, as I hardly ever used macros.?
The data macro also sounds a better idea, just they are not available in 2007.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba