AfterUpdate for ALL Fields?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help!

I have a form that has dozens of fields of various control types (text,
checkbox, drop down, list box, etc). I need to run a piece of code if ANY
field changes value (regardless of type). I COULD set up an afterupdate
event for each field on the form, but that would be a lot of work and be
really ugly.

Any ideas?

Thanks!
 
You can use the Form Before Update event to check if there were changes to
the record

If Me.Dirty Then ' Record has changed


Note: if you change a field value and then you chane it back to the original
value t will still act like the record has changed

You can also check each field separatly if the value changed on the same
event.

If me.FieldName <> me.FieldName.OldValue Then ' value has changed
 
Thanks Ofer!

I think this may work...






Ofer Cohen said:
You can use the Form Before Update event to check if there were changes to
the record

If Me.Dirty Then ' Record has changed


Note: if you change a field value and then you chane it back to the original
value t will still act like the record has changed

You can also check each field separatly if the value changed on the same
event.

If me.FieldName <> me.FieldName.OldValue Then ' value has changed
 
PK said:
Thanks Ofer!

I think this may work...

You actually don;t need to test the Dirty property. If the BeforeUpdate event
of the form is called then by definition, at least one field has been changed.
 

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

Back
Top