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
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 ......)
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.
Re: Logging field changes by a User
Hi,
Would the tag property be able to accomodate multiple lines of data from a multiline textbox.
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?
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:thumb:
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.....
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.:wave:
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 ??
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?
Re: Logging field changes by a User
yes hack, that is correct.
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?