Who Last Modified???

Mike Vytal

Registered User.
Local time
Today, 10:56
Joined
Feb 1, 2007
Messages
34
Access 2007 -- LOVE IT OR HATE IT??? I have a macro:

SetValue
Item: User
Expression: CurrentUser

SetValue
Item: LastUpdated
Expression: Now()


The macro is called "Last Modified", and I have it set to the After_Update property. I have even tried the following:

Private Sub Form_AfterUpdate()
Me.Refresh
Me!User = CurrentUser
Me!LastUpdated = Now()
End Sub


All I want is for the User & LastUpdated fields to be populated once a user makes a change to the record. In Access 2003, the macro worked fine! In '07, I have to hit the 'Esc' button to advance to the next record when either the macro or code is implemented. Please Help!!! Thanks....
 
Don't use the After Update property. You will potentially get into a nasty loop. Think about it this way - If you set the value in the After Update event, the value will be set to the current date/time. The update events will then fire again which will then be a different time and then it will set the value again and again and again.

Change it to the BEFORE update event and see if that doesn't work for you.
 
Bob, thanks for the quick response, but the Before_Update updates those fields regardless of if I change any of the data or not. I only want the values to change if the data is modified in any way.
 
The before update event will ONLY fire if the form is dirty (which means that data has changed).
 
Bob,

I don't update any info, just advance to the next record. When I come back, the fields have been populated. Am I doing something wrong?

Also, another question. In a query, how can I write an expression that returns records with an expiration date of 2 years to the day?? In other words, I need everyone from 4/4/06 until now...

Thanks Bob.
 
the form is dirty (which means that data has changed).
Side note (WAY off to the side, that is):

A form is dirty only if data has changed within the bound construct of the form. You can edit values in unbound controls until the cows come home, and your form will be just as clean as if you didn't even touch it...
 
Side note duly noted. Solution: I just created another table called "User Trail" and used it as the source for a subform. Then added code to update the two fields in the subform...works fine.

Thanks for the help guys...
 
you must have some code modifying data on entry - if you are using record selectors you will probably see the black arrow has changed into a pencil, which indicates the record is in a "edited/dirty" state
 

Users who are viewing this thread

Back
Top Bottom