I have a multi user DB and added in a ChangeLog. I am tracking changes made to one particular field in one of the forms.
Here's the function:
Code:
Function ChangeLog(lngID As Long, Optional strField As String = "", Optional strChangeSummary 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
!Change = strChangeSummary
!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
I then call it in the form field's before update event:
Code:
Private Sub txtFollowUp_BeforeUpdate(Cancel As Integer)
Call ChangeLog(ComplaintNumber, "FollowUp", "Updated complaint follow-up")
End Sub
It's working well for me, but two users have had both had an error message pop up which states "The expression Before Update you entered as the event property setting produced the following error: The expression you entered requires the control to be in the active window."
I'm not sure what that means. Idk why the expression wouldn't be in the active window. I also haven't gotten this error myself so it's difficult to triage. The users state that they change the field's value and go to save, and then that error pops up
Any suggestions on what the issue might be?