Form Record Update-HEELP.

Liv Manto

Registered User.
Local time
Today, 18:12
Joined
Apr 26, 2001
Messages
266
I am creating a log of edited records.

So let's say I have two fields:

NAME, AGE

Say my present Record is

NAME- Liv Manto
AGE- 28


If a user say, User 8 change the record to:

NAME - Olivia Gonzales
AGE - 32

I will a add a record to a log table EDIT:

User08;Name-Liv Manto:Olivia Gonzales;AGE-24:32

SO I would make use of the Old Value compared to New Value.

I put the code that would add this record to the AFTER Update Event of the Program.

My problem is after I update the first field, LivManto to Olivia, the record is automatically refresh so when I change the AGE, my oldvalue for NAME becomes Olivia instead of LivManto.

I am not using refresh so I have no idea how to fix this.

Please Help.

Where do I put the code. The On Dirty Event offers the same dilemma.
 
Just a shot in the dark. This event/ that event...will drive you madd!

Maybe some code to copy the current record on the OnCurrent event of the form, then on the AfterUpdate, do a paste.

Like I said, just a shot.
 
liv,

put a couple of unbound text controls on your form (hidden), then as jwindon suggests use the OnCurrent event to populate them with the old values from your table/query.

in the afterupdate output: user,hidden1,hidden2,Name,Age to your log...

hth,
al
 
Place the code in the BeforeUpdate event of your Form. The AfterUpdate event has already saved the data to the database, so it doesn't remember the old values. BeforeUpdate hasn't committed the changes yet, so the old values are still available.

HTH
SteveA
 
SteveA,

not sure what you are suggesting...but i think the BeforeUpdate event will fire for each control on the form...and if you want to preserve the initial values, that won't work.

al
 
Al,

By placing the code in the BeforeUpdate event of the Form, it is only triggered when the user attempts to move away from the current record (whether it be closing the form or moving to another record). It will not trigger as the user is updating the individual fields unless these fields are asking Access to save the record (ie Me.Dirty = False in the AfterUpdate event of a control will force the record to try and save).

I have implemented this approach myself with no problems.

Cheers,
SteveA
smile.gif
 

Users who are viewing this thread

Back
Top Bottom