Results 1 to 12 of 12

Thread: Logging field changes by a User

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Logging field changes by a User

    Hi guys,

    I need to log each change made to a field by a user. Fields such as Firstname,ID Number and so forth.

    What would be the easiest way to accomplish this. I was thinking of having two UDT's. In the first UDT I would store all the information on the form load. In the second UDT I would store the information once the user clicks save, and the I would compare the corresponding values of both UDT's and log the changed ones.

    Am I on the right track here. I'd love to get your opinions.

    Regards,
    Nitesh

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Logging field changes by a User

    Depending on the data entry size (you mention Id's etc) you could duplicate the controls .Text in it's .Tag property at Form_Load. And then later compare what is in the controls .Text against its .Tag and do whatever.

    (If Text1.Text = Text1.Tag Then ......)

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Logging field changes by a User

    How about using .Tag as goes from Bruce's advice, and simply enable/disable the 'save' button? For example (if you have a control array of TextBox-es):
    Code:
    Option Explicit
    
    Private Sub form_load()
        fillTags
    End Sub
    
    Private Sub Text1_Change(Index As Integer)
        If Text1(Index).Text <> Text1(Index).Tag Then
            Command1.Enabled = True
        End If
    End Sub
    
    Private Sub Command1_Click()
        'save procedure here...
    
        MsgBox "Saved!"
    
        fillTags
    End Sub
    
    Private Sub fillTags()
        Dim n As Long
    
        For n = Text1.LBound To Text1.UBound
            Text1(n).Tag = Text1(n).Text
        Next n
    
        Command1.Enabled = False
    End Sub
    That way the user always knows where he's at.

  4. #4

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Logging field changes by a User

    Hi,

    Would the tag property be able to accomodate multiple lines of data from a multiline textbox.

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Logging field changes by a User

    Yep.

    For what it's worth, how much data do you need to styore - noting you mention username, ID's etc?

  6. #6

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Logging field changes by a User

    Thanks guys,

    I have 25 textboxes on the current tab but I have to do this for each tab and I have about 9 tabs. So there's quite alot

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Logging field changes by a User

    Sorry, the question is how much data (lines of text, number of characters) per control (textbox)?

    I think the .Tag can store about 64k.....

  8. #8

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Logging field changes by a User

    oh ok,

    for fields such as medical details dor example i have a multiline texbox, data could be a few lines or 1 word. For surnames and stuff I would be just storing a few characters.

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Logging field changes by a User

    BTW, The .Tag property may not be included in VB.Net. So if in future if you choose to port you app to VB.Net it may fall over! - some reserach required

    Anyone ??

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Logging field changes by a User

    What are you doing with the data in the 25 textboxs?

    Are you storing that in a back end db?

  11. #11

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Logging field changes by a User

    yes hack, that is correct.

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Logging field changes by a User

    Then instead of fooling around with the textboxs, why not just keep track of who made database changes?

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