gojets1721
Registered User.
- Local time
- Yesterday, 18:49
- Joined
- Jun 11, 2019
- Messages
- 430
I have a table that captures changes made to my form's fields. Here's the module's code:
Then I call the module in a specific's field's before update event:
My question is: is it possible to alter this code so that it tracks every field in the form? If I wanted to do that right now, I'd have to call the module individually in every field's before update event which doesn't seem ideal (i have 60-70 fields in this form).
I was wondering if it's possible to alter the code so that it could just call it in the form's before update event or elsewhere
Code:
Function ChangeLog(lngID As Long, Optional strField As String = "")
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim varOld As Variant
Dim varNew As Variant
Dim strFormName As String
Dim strControlName As String
varOld = Screen.ActiveControl.OldValue
varNew = Screen.ActiveControl.Value
strFormName = Screen.ActiveForm.Name
strControlName = Screen.ActiveControl.Name
Set dbs = CurrentDb()
Set rst = CurrentDb.OpenRecordset("tblChangeLog", dbOpenDynaset, dbSeeChanges)
With rst
.AddNew
!FormName = strFormName
!ControlName = strControlName
If strField = "" Then
!Fieldname = strControlName
Else
!Fieldname = strField
End If
!EventNumber = lngID
!Username = Username()
!StaffMemberName = StaffName()
!TimeStamp = Now()
If Not IsNull(varOld) Then
!OldValue = CStr(varOld)
End If
!NewValue = CStr(varNew)
.Update
End With
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Function
Then I call the module in a specific's field's before update event:
Code:
Private Sub txtFollowUp_BeforeUpdate(Cancel As Integer)
Call ChangeLog(ComplaintNumber, "FollowUp")
End Sub
My question is: is it possible to alter this code so that it tracks every field in the form? If I wanted to do that right now, I'd have to call the module individually in every field's before update event which doesn't seem ideal (i have 60-70 fields in this form).
I was wondering if it's possible to alter the code so that it could just call it in the form's before update event or elsewhere