Results 1 to 3 of 3

Thread: [RESOLVED] Track Changes in table....(MS ACCESS)

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] Track Changes in table....(MS ACCESS)

    Iok.. I need to track all changes in a table...
    The only way to access the table is thru a subform hooked in...

    Now in playing with the before/after updates... I see I can hit these and record the change after update.... but it will be a MAJOR pain to do this code for EACH field... not only that.. just realized that if I change one field.. move to the next in the same record.. then hit esc.. it cancels the change!

    here is what I have so far.. (Just for one field)
    there must be a better way to do this....
    VB Code:
    1. Private Type tData
    2.     RecNum As Integer
    3.     PrevVal As String
    4.     NewVal As String
    5.     FieldName As String
    6. End Type
    7.  
    8. Dim FLD As tData
    9.  
    10. Private Sub LOGCHANGE()
    11.     Debug.Print FLD.FieldName
    12.     Debug.Print FLD.RecNum
    13.     Debug.Print FLD.PrevVal
    14.     Debug.Print FLD.NewVal
    15. End Sub
    16.  
    17.  
    18. Private Sub ADDRESS_AfterUpdate()
    19.     FLD.NewVal = ADDRESS.Value
    20.     FLD.FieldName = "ADDRESS"
    21.     LOGCHANGE
    22. End Sub
    23.  
    24. Private Sub ADDRESS_BeforeUpdate(Cancel As Integer)
    25.     FLD.PrevVal = ADDRESS.OldValue
    26.     FLD.RecNum = Me.CurrentRecord
    27. End Sub

    Thanks!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Track Changes in table....(MS ACCESS)

    If I understand you correctly, what you want is to record some or all values of a record prior to an update, and record what changes were made. You could do this by writing to and reading from a text file.
    If this is what you want, I had a similar problem that I solved by writing old values to a table before the update took place, then writing the new values to another table after the update, to maintain a synchronous log (the values are updated in the main table, of course).
    This gives a table of old values and a table of new values. For my department, this is usefull because other people (aka bosses) might want to revert the changes.
    If you'd like the code, no problem. Well, one problem, VBforums still doesn't always recognize me, so I may not see your reply in a timely manner.
    Mods, yes, I've deleted all cookies that seem to relate to this site, several times. Recognizes me for a while, then stops.
    Tengo mas preguntas que contestas

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Track Changes in table....(MS ACCESS)

    yes, what I want is to record each fields change... it took a bit but I created sub forms in access, and in each text field I run a function in the before/after update events. the changes are put into a table.. date/time/user/old val/new val/fieldname/recordnum seems to be working nicely.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width