View Full Version : Form Record Update-HEELP.


Liv Manto
10-26-2001, 02:56 PM
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.

jwindon
10-26-2001, 03:29 PM
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.

pcs
10-26-2001, 03:51 PM
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

SteveA
10-26-2001, 08:11 PM
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

pcs
10-26-2001, 09:16 PM
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

SteveA
10-27-2001, 01:01 AM
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 http://www.access-programmers.co.uk/ubb/smile.gif

pcs
10-27-2001, 09:30 AM
gotcha ! thanks!

al