Afterupdate when and how

T

toine

I have a form 'klaarzetten' in which I want to track changes made on
the form.The form contains two subforms.
The table 'Klaarzetten' contains two fields (veranderop-(date),
veranderddoor-(numeric)).
I want to track changes in the mainform and both the subforms. Only
the last changes are important to me and I want to register the date
on which the last change is made and the loginname.
I tried to use the forms afterupdate event to write the data in the
table but I got al lot of errors, perhaps because the afterupdate
event is processed when the form close button is pressed?
The event works well when I call it with each control change() event.
But this means that every time a field is changed, the name and date
is written and causes a lot of unwanted data traffic.
What is the best solution to this problem?
 
A

Al Camp

Use the BeforeUpdate event of the form/subform to set your date/time
values.
On my website, I have a small downloadable app that utilizes DOC
(DateOfCreation) and DOLE (DateOfLastEdit).
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
A

Allen Browne

Use the BeforeUpdate event of the *form* (not controls).

This is the last moment to write the date and user name before the record is
saved.

There is no point dirtying the record again immediately after the save (as
Form_AfterUpdate does), because you then need to save again, which triggers
the event again, and so you need to save again, and ...
 
G

Guest

Would this same principle work when you want to track a "Status Change" to a
record? Can you set it to record the prior status and the date it was
changed?
 
A

Allen Browne

If you are trying to log changes to another table, then you want to write
them only in Form_AfterUpdate, when you know for sure the change succeeded.
But the OldValue is not available then, so you need to save it somewhere
(variable or temp table) in Form_BeforeUpdate, so you have it in
Form_AfterUpdate.

If you are also trying to record deletions, things get more involved. For
details, see:
Audit Trail - Log changes at the record level
at:
http://allenbrowne.com/AppAudit.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top