Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

keeping an audit trail

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnE - 25 Nov 2005 02:20 GMT
Hello all.  I have a form in which is only used to add or update records.  A
field on the table and field in the form is for keeping track of all updates
of each record at the record level.  I am using the following coding to do
so.  The table field is called ProjectDevelopmentApplicationAudit and the
field on the form is called txtProjectDevelopmentApplicationAudit.  

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Err GoTo TryNextC
   Dim MyForm As Form
   Dim ctl As Control
   Dim strUser As String
   Set MyForm = Screen.ActiveForm
   strUser = fOSUserName

' Set date and current user if form has been updated.
   MyForm!txtProjectApplicationDevelopmentAudit =
MyForm!txtProjectApplicationDevelopmentAudit & Chr(13) & Chr(10) & vbCrLf & _
       "Record changed or modified on " & Now & " by " & strUser & ";"

' If new record, record it in audit trail and exit sub.
   If MyForm.NewRecord = True Then
      MyForm!txtProjectApplicationDevelopmentAudit =
MyForm!txtProjectApplicationDevelopmentAudit & Chr(13) & Chr(10) & "NEW
RECORD"
      Exit Sub
   End If

' Check each data entry control for change and record old value of Control.

   For Each ctl In MyForm.Controls

' Only check data entry type controls.
      Select Case ctl.ControlType
         Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox
            If ctl.Name = "txtProjectApplicationDevelopmentAudit" Then GoTo
TryNextC ' Skip txtProjectApplicationDevelopmentAudit field.
           
            If ctl.Value <> ctl.OldValue Then
               MyForm!txtProjectApplicationDevelopmentAudit =
MyForm!txtProjectApplicationDevelopmentAudit & Chr(13) & Chr(10) & "CHANGED
or MODIFIED" & vbCrLf & _
                   "   " & "FIELD:  " & ctl.Name & vbCrLf & "   " & "FROM:  
" & ctl.OldValue & _
                   vbCrLf & "   " & "TO:  " & ctl.Value
            End If
      End Select
TryNextC:
        Next ctl

End Sub

I do not get any error messages but I don't see any info in the table field
either.  I am in a quandry over this.  If anyone can assist and see what is
wrong with this, I say thank you in advance.
*** John
JohnE - 25 Nov 2005 05:42 GMT
Hi there.  Please disregard the issue below.  I finally figured it out.  
Thank you for taking the time to look at this.
*** John

> Hello all.  I have a form in which is only used to add or update records.  A
> field on the table and field in the form is for keeping track of all updates
[quoted text clipped - 51 lines]
> wrong with this, I say thank you in advance.
> *** John
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.