mattkorguk
Registered User.
- Local time
- Today, 00:48
- Joined
- Jun 26, 2007
- Messages
- 301
Hi,
I'm trying to monitor a few fields and record who updated them together with the old and new values, so far, I have this;
This does work ok, I was just wondering if there's a way of refering to the current field, rather than having to specify 'me.NPW.oldvalue' etc.
Cheers
Matt
I'm trying to monitor a few fields and record who updated them together with the old and new values, so far, I have this;
This does work ok, I was just wondering if there's a way of refering to the current field, rather than having to specify 'me.NPW.oldvalue' etc.
Cheers
Matt
Code:
Private Sub NPW_AfterUpdate()
Call LogFieldUpdate(Me.AppNumber, "NPW", Me.NPW.OldValue, Me.NPW)
End Sub
Code:
Public Function LogFieldUpdate(appNo As Long, fldName As String, oValue As String, nValue As String)
' Purpose: Log updates to selected fields to track who is updating.
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim fldSQL As String
Set db = CurrentDb()
fldSQL = "INSERT INTO _FieldUpdates ( AppNo, oFieldValue, nFieldValue, FieldName, UserName ) " _
& "SELECT " & appNo & ", " & Format(oValue, "ddmmyyyy") & ", " & Format(nValue, "ddmmyyyy") & ", '" & fldName & "', '" & [Forms]![switchboard].[UserName] _
& "';"
DoCmd.SetWarnings False
DoCmd.RunSQL fldSQL
DoCmd.SetWarnings True
End Function