-
Audit table
I am able to keep track of record changes. But I also need to add the Order ID to be used in reports. Since the Order ID doesn't changed, it's not captured on my audit table. Can someone help me to also include the Order ID. Thanks!
Public Function WriteAudit(frm As Form, lngID As Long) As Boolean
On Error GoTo err_WriteAudit
Dim ctlC As Control
Dim strSQL As String
Dim bOK As Boolean
bOK = False
DoCmd.SetWarnings False
' For each control.
For Each ctlC In frm.Controls
If TypeOf ctlC Is TextBox Or TypeOf ctlC Is ComboBox Then
If ctlC.Value <> ctlC.OldValue Or IsNull(ctlC.OldValue) Then
If Not IsNull(ctlC.Value) Then
strSQL = "INSERT INTO tblAudit ( ID, FieldChanged, FieldChangedFrom, FieldChangedTo, DateOfHit ) " & _
" SELECT " & lngID & " , " & _
"'" & ctlC.Name & "', " & _
"'" & ctlC.OldValue & "', " & _
"'" & ctlC.Value & "', " & _
"'" & Now & "'"
'Debug.Print strSQL
DoCmd.RunSQL strSQL
End If
End If
End If
Next ctlC
WriteAudit = bOK
exit_WriteAudit:
DoCmd.SetWarnings True
Exit Function
err_WriteAudit:
Resume exit_WriteAudit
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|