lacampeona
Registered User.
- Local time
- Today, 13:49
- Joined
- Dec 28, 2015
- Messages
- 392
Hello
i have a form and some memo field called Updates.
When i make changes on my form (called frmA ) the module audit data write all the audit data to the memo field called Updates. this is working perfectly.
now i want to make also audit data on my subform.
i try the same module but i notice that when the form is working as single form audit data is working...but when i put the form as subform then the module and audit data is not working.
i am sure that has something to do with the the code writen in the module.
the screen.active form. and the field uptades..maybe i have to put uptades on the main form...and then uptades2 on the subform?
can somebody help me
how i can use my module that will show me audit data in the field uptades2? also on my subform?
Option Compare Database
Public Function AuditData()
' Comments : This function is used to provide an audit trail of all changes to a record
' : entered on a secured form. After adding a locked memo field called 'Updates'
' : on the source form, add a reference to the Before Update event to this function.
' Requirement: A bound memo field named 'Updates' must exist on the active form
' Parameters : None
' Returns : Appends Audit Trail data as a string to the memo field on the active form
' Created By : Ofni Systems Inc.
' Modified : 04/07/01
' --------------------------------------------------------
Dim frmActive As Form
Dim ctlData As Control
Dim strEntry As String
Dim User As String
Dim Who As String
Who = TempVars!UserName
User = CreateObject("wscript.network").ComputerName
Set frmActive = Screen.ActiveForm
'Set date and current user if form has been updated.
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & _
"----------------------------------------------------------------------------------------------" & Chr(13) & Chr(10) & _
"Changes made on " & Date & " " & Time & " by " & Who & ";"
'Determine who, when and where
strEntry = " by " & Who & " on " & Now
' If new record, record it in audit trail and exit sub
If frmActive.NewRecord = True Then
frmActive!Updates = frmActive!Updates & "New Record Added" & strEntry
'Uncomment the next line if you do not want to record the details of the initial entry
'Exit Function
End If
'Check each data entry control for change and record
For Each ctlData In frmActive.Controls
' Only check data entry type controls
Select Case ctlData.ControlType
Case acTextBox, acComboBox, acCheckBox, acOptionButton
' Skip Updates field
If ctlData.Name = "Updates" Then GoTo NextCtl
'Skip unbound controls (3 is ControlSource)
Select Case IsNull(ctlData.Value)
'Check for deleted data
Case True
If Not IsNull(ctlData.OldValue) Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " Data Deleted: Old value was '" & ctlData.OldValue & "'" & strEntry
End If
'Check for new or changed data
Case False
If IsNull(ctlData.OldValue) And Not IsNull(ctlData.Value) Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " Data Added: " & ctlData.Value & strEntry
'If control had previous value, record previous value
ElseIf ctlData.Value <> ctlData.OldValue Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " changed from '" & ctlData.OldValue & "' to '" & ctlData.Value & "'" & strEntry
End If
End Select
End Select
NextCtl:
Next ctlData
End Function
i have a form and some memo field called Updates.
When i make changes on my form (called frmA ) the module audit data write all the audit data to the memo field called Updates. this is working perfectly.
now i want to make also audit data on my subform.
i try the same module but i notice that when the form is working as single form audit data is working...but when i put the form as subform then the module and audit data is not working.
i am sure that has something to do with the the code writen in the module.
the screen.active form. and the field uptades..maybe i have to put uptades on the main form...and then uptades2 on the subform?
can somebody help me
how i can use my module that will show me audit data in the field uptades2? also on my subform?
Option Compare Database
Public Function AuditData()
' Comments : This function is used to provide an audit trail of all changes to a record
' : entered on a secured form. After adding a locked memo field called 'Updates'
' : on the source form, add a reference to the Before Update event to this function.
' Requirement: A bound memo field named 'Updates' must exist on the active form
' Parameters : None
' Returns : Appends Audit Trail data as a string to the memo field on the active form
' Created By : Ofni Systems Inc.
' Modified : 04/07/01
' --------------------------------------------------------
Dim frmActive As Form
Dim ctlData As Control
Dim strEntry As String
Dim User As String
Dim Who As String
Who = TempVars!UserName
User = CreateObject("wscript.network").ComputerName
Set frmActive = Screen.ActiveForm
'Set date and current user if form has been updated.
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & _
"----------------------------------------------------------------------------------------------" & Chr(13) & Chr(10) & _
"Changes made on " & Date & " " & Time & " by " & Who & ";"
'Determine who, when and where
strEntry = " by " & Who & " on " & Now
' If new record, record it in audit trail and exit sub
If frmActive.NewRecord = True Then
frmActive!Updates = frmActive!Updates & "New Record Added" & strEntry
'Uncomment the next line if you do not want to record the details of the initial entry
'Exit Function
End If
'Check each data entry control for change and record
For Each ctlData In frmActive.Controls
' Only check data entry type controls
Select Case ctlData.ControlType
Case acTextBox, acComboBox, acCheckBox, acOptionButton
' Skip Updates field
If ctlData.Name = "Updates" Then GoTo NextCtl
'Skip unbound controls (3 is ControlSource)
Select Case IsNull(ctlData.Value)
'Check for deleted data
Case True
If Not IsNull(ctlData.OldValue) Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " Data Deleted: Old value was '" & ctlData.OldValue & "'" & strEntry
End If
'Check for new or changed data
Case False
If IsNull(ctlData.OldValue) And Not IsNull(ctlData.Value) Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " Data Added: " & ctlData.Value & strEntry
'If control had previous value, record previous value
ElseIf ctlData.Value <> ctlData.OldValue Then
frmActive!Updates = frmActive!Updates & Chr(13) & Chr(10) & " " & ctlData.Name & " changed from '" & ctlData.OldValue & "' to '" & ctlData.Value & "'" & strEntry
End If
End Select
End Select
NextCtl:
Next ctlData
End Function