capture Field Name when changes made

mcgraw

Registered User.
Local time
Today, 08:33
Joined
Nov 13, 2009
Messages
77
I would like to know how to have access pull the name of the field that had data changed in it.

I have a form, that has AfterUpdate set to the following...

Set rs = CurrentDb.OpenRecordset("Audit")
With rs
.AddNew
!tblProject_ID = Me.ID
!last_update = Now()
!updated_by = fOSUserName()
!FieldName = Field.Name
.Update
End With

Everything works, but the FieldName function. How can I get Access to tell me which field had a change made to it? I put the Field.Name in there as a shot in the dark. :)

Any help would be GREATLY appreciated!
 
there is not an easy way to do it, but each input type control has a dirty event attached to it. perhaps you could use that to capture the indication. either that, or store it in a variable i spose.
 
There could be many fields that have changed based on the little information you have supplied so far. All of the Controls where the .OldValue does not match the .Value have changed.
 
I would loop through the controls and compare the .Value and .OldValue properties of the appropriate controls.
 
Sorry RG, your post wasn't there when I started typing. I think the cold weather slowed my fingers down. :p
 
There could be many fields that have changed based on the little information you have supplied so far. All of the Controls where the .OldValue does not match the .Value have changed.

Just thought I would point out this little thing as a potential "gotcha" (as I was burned by it and it took a lot to find this info and then deal with it). Not likely going to affect things in this situation but you should be aware of it.
 
I'm sure the OP will appreciate the confirmation post Paul. I have noticed you folks are getting quite a wallop from Global Warming. Are we having fun yet?
 
Whatever wallop we get usually hits you the next day, does it not? Hope you didn't get the ferocious winds we got Friday. Several people I know lost fences and/or trees. We just lost one branch off a tree. That day was fun!
 
Actually the whole 4 Corners Area is having it pretty mild right now. Only two decent storms so far this year and not much on the horizon. Take care buddy.
 
you can create a function that will do what ever you wish to do with the name of the control, and use the dirty, beforeUpdate or afterUpdate events of each control to send it's name (me.name) to the function.
 

Users who are viewing this thread

Back
Top Bottom