Going through all text/combo boxes on form, when user changes reco

J

Jarda Beran

Hi,
I have form with some nested sub-forms, and I need to go through all
textboxes and combo boxes, when user changes data (Dirty event). I'm using
Access 2003.
Is there a way, how to do it?
Thanks for any advice

Jarda

PS: I've tried to code something myself, but perhaps I'm a little bit
unclear on using .OldValue property. I've tried to compare .OldValue and
..Value of textbox or combo box, and when it wasn't equal, then save to log,
what was changed by user - but it didn't work.
 
D

Dale Fye

You might want to check out http://www.allenbrowne.com/AppAudit.html
on Allen Browne's website. If this isn't exactly what you are looking for,
it should definately give you some ideas.

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
A

Allen Browne

So you are trying to log what was changed?

The form's Dirty event is too early. It fires before the user has edited
things. Form_AfterUpdate is the first event you have when you know the edits
were succesfully saved.

Unfortunatly, the OldVaue of controls is not available in Form_AfterUpdate,
so you will need to use Form_BeforeUpdate to compare the Value and OldValue
of the editable controls bound to fields, store them in some place (e.g.
array or temporary table), read them in Form_AfterUpdate, and write them to
your logging table.

Don't forget to handle the nulls. The cases to log would be:
- field previously had one value, and now has another;
- field was previouslly null, and now has a value;
- field previously had a value, and now is null.

Have you considered how you will log the deletions?

There is an example here of logging the edits, inserts, and deletions:
Audit Trail - Log changes at the record level
at:
http://allenbrowne.com/AppAudit.html
This one does not loop through all controls comparing old and new values; it
just logs them all (which is what you want for deletions anyway.)
 
J

Jarda Beran

Thank you, you have a very usefull website - there is a lot of information
for me, as I am just let's say "advanced user" :)

Thank you again
 

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