Tony A. said:
Can you track the changes that are made to a record in access? Does
anyone know how to do this?
Yes. In the before update event of the form, grab the OldValue property of
each control and insert that value into an audit table, together with the
date\time of the record change, and the username of the person doing it.
Here's one sample (aircode):
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Handler
Dim lngItemID As Long
Dim strContractorID As String
Dim strSubdivision As String
Dim lngModelID As Long
Dim dblCost As Double
Dim dblCostCode As Double
Dim dtmEffectiveDate As Date
Dim db As DAO.Database
Dim strSQL As String
lngItemID = Me.txtItemID.OldValue
strContractorID = Me.txtContractorID.OldValue
strSubdivision = Me.txtSubdivision.OldValue
lngModelID = Me.txtModelID.OldValue
dblCost = Me.txtCost.OldValue
dblCostCode = Me.txtCostCode.OldValue
dtmEffectiveDate = Me.txtEffectiveDate.OldValue
Set db = CurrentDb
Me.txtLastUpdated = Now
strSQL = "INSERT INTO tblItemHistory ( ItemID, Subdivision, ModelID,
CostCode, Cost, ContractorID, EffectiveDate )"
strSQL = strSQL & " VALUES (" & lngItemID & ", '" & strSubdivision & "',
" & lngModelID & ", " & dblCostCode & ", " & dblCost & ", '" &
strContractorID & "', '" & dtmEffectiveDate & "');"
db.Execute strSQL
Exit_Here:
Exit Sub
Err_Handler:
MsgBox Error$
Me.Undo
Resume Exit_Here
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access