Hi, folks,
I have added audit columns (created_by, created_date, last_edited_by, last_edited_date) to all of the tables in my database. By the following code (taken from a FAQ on this site) to the BeforeInsert and BeforeUpdate event properties on my forms, I am now able to populate the audit fields automatically whenever a user adds or edits a record:
Unfortunately, I now have to add this code to the event properties of every form in my database.
Is there a way to encapsulate this code as a module, or as some kind of function, that can be called from every form?
Thanks,
M
I have added audit columns (created_by, created_date, last_edited_by, last_edited_date) to all of the tables in my database. By the following code (taken from a FAQ on this site) to the BeforeInsert and BeforeUpdate event properties on my forms, I am now able to populate the audit fields automatically whenever a user adds or edits a record:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!Created_By = CurrentUser()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!Last_Updated_By = CurrentUser()
Me!Last_Updated_Date = Now()
End Sub
Unfortunately, I now have to add this code to the event properties of every form in my database.
Is there a way to encapsulate this code as a module, or as some kind of function, that can be called from every form?
Thanks,
M