Hi...I really need help!
I have an audit trail running that keeps a change log in a single table using the code:
Everything runs fine, but now the boss wants a report that displays the information like this:
Record # Date of Change Reason for Change Current Values Old Values
1 (some date) (some reason) QTY: (new qty here) QTY: (old qty here)
2 (some date) (some reason) PRICe: (new price here) PRICE: (old price here
Each specific item has it's own record #, which repeats in the audit table when multiple changes are made to the same item. Since the audit log table stores all new values in one line at a time, the previous value is actually the previous row. Wouldn't I have to be able to somehow pull the 2nd to last version of each record # (ie, the 2nd to last row for that record # in the table) in order to put the new and previous values side-by-side like that? And how is that even done?
Sorry if this description was long, but I'm confused and frustrated and really need help. Thank you!!
I have an audit trail running that keeps a change log in a single table using the code:
Code:
Private Sub Form_AfterUpdate()
Dim db As Database
Set db = CurrentDb
db.Execute "INSERT INTO [tblDatabaseChanges] " _
& " SELECT * FROM [tblEquipmentDatabase] WHERE " _
& " [tblEquipmentDatabase].[RecordID]=" & Me![RecordID] & ";"
Set db = Nothing
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error Resume Next
Dim blnCheckDiff As Boolean
Dim ctl As Control
blnCheckDiff = False
For Each ctl In Me.Controls
If ctl.Tag = "Check" And ctl.Value <> ctl.OldValue Then
blnCheckDiff = True
Me!DateofChange = Date
End If
Next
If blnCheckDiff Then
[txtTime] = Now()
[txtuser] = [txtCurrentUser]
Else
Cancel = True
End If
End Sub
Everything runs fine, but now the boss wants a report that displays the information like this:
Record # Date of Change Reason for Change Current Values Old Values
1 (some date) (some reason) QTY: (new qty here) QTY: (old qty here)
2 (some date) (some reason) PRICe: (new price here) PRICE: (old price here
Each specific item has it's own record #, which repeats in the audit table when multiple changes are made to the same item. Since the audit log table stores all new values in one line at a time, the previous value is actually the previous row. Wouldn't I have to be able to somehow pull the 2nd to last version of each record # (ie, the 2nd to last row for that record # in the table) in order to put the new and previous values side-by-side like that? And how is that even done?
Sorry if this description was long, but I'm confused and frustrated and really need help. Thank you!!