I'm using the code and table structure pulled together by Joseph G. Njoroge (https://community.spiceworks.com/topic/1961724-audit-trail-for-access-database).
My issue is that it isn't picking up the AutoNumber Primary Key (Name_ID) for new records when writing the NEW row to the tblAuditTrail. Thoughts on modifying the code to get this key piece of information?
Here's how it currently looks, with the RecordID field showing blank for the NEW records. I want to pick up the autonumber that is generated when you leave the record.
I've tried moving the NewRecord portion of the code to the AfterUpdate but that didn't result in a change.
My issue is that it isn't picking up the AutoNumber Primary Key (Name_ID) for new records when writing the NEW row to the tblAuditTrail. Thoughts on modifying the code to get this key piece of information?
Here's how it currently looks, with the RecordID field showing blank for the NEW records. I want to pick up the autonumber that is generated when you leave the record.
I've tried moving the NewRecord portion of the code to the AfterUpdate but that didn't result in a change.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Call AuditChanges("Name_ID", "NEW")
Else
Call AuditChanges("Name_ID", "EDIT")
End If
End Sub
Private Sub Form_AfterDelConfirm(Status As Integer)
If Status = acDeleteOK Then Call AuditChanges("Name_ID", "DELETE")
End Sub