Sorry to better explain myself...
I have currently set up a Userform (which opens in Datasheet view), this form is what users will be using to work with the database within Access.
Here is the Userform (still in example form):
Now in each of the fields of the userform (in design mode) I have created this VBA code behind the form:
Code:
Private Sub ETA_BeforeUpdate(Cancel As Integer)
Call LogChanges(HB, "ETA")
End Sub
Private Sub Status_BeforeUpdate(Cancel As Integer)
Call LogChanges(HB, "Status")
End Sub
Function LogChanges(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 strControlName As String
varOld = Screen.ActiveControl.OldValue
varNew = Screen.ActiveControl.Value
strControlName = Screen.ActiveControl.Name
Set dbs = CurrentDb()
Set rst = dbs.TableDefs("tbl_Changes").OpenRecordset
With rst
.AddNew
If strField = "" Then
!FieldName = strControlName
Else
!FieldName = strField
End If
!HB = lngID
!UserName = Environ("username")
If Not IsNull(varOld) Then
!OldValue = CStr(varOld)
End If
!NewValue = CStr(varNew)
.Update
End With
'clean up
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
End Function
This code logs all changes to each field by any user into the tbl_Changes table.
Now if in the userform, if I were to on HB 70, tick status and change the ETA, and then on HB 80 untick status and change the ETA. This code automatically records these changes in tbl_Changes, and will look like this:
This is working perfectly at the moment for all changes made via a userform which is something I need. What I dont know how to do is do the same recording of changes but do it when I do my Update Query?
Is this possible?
Thanks