Here's the code.
Public Function StampRecord(frm As Form, Optional bHasInactive As Boolean = False) As Boolean
On Error GoTo Err_StampRecord
'Purpose: Stamp the user and date/time into the record.
'Return: True if successful.
'Argument: frm = the bound form to be stamped.
' bHasInactive= True if the form has Inactive fields.
'Assumes: Fields named EnteredOn, EnteredBy, UpdatedOn, and UpdatedBy.
'Usage: In Form_BeforeUpdate:
' Call StampRecord(Me, True)
Dim strForm As String
Dim strUser As String
strForm = frm.Contactsfrm 'For error handler.
strUser = NetworkUserName()
If frm.NewRecord Then
frm!EnteredOn = Now()
frm!EnteredBy = strUser
Else
frm!UpdatedOn = Now()
frm!UpdatedBy = strUser
End If
Exit_StampRecord:
Exit Function
Err_StampRecord:
Call LogError(Err.Number, Err.Description, conMod & "StampRecord()", "Form = " & strForm)
Resume Exit_StampRecord
End Function