Finding Dirty/Changed Controls???

G

Guest

Hi,
I have a form with 45-60 controls, a mix of checkboxes, textboxes, and
comboboxes. My users would like to have a continuous historical record of
changes to each record on the form. Is there an easy way to cycle or loop
through each of the controls to see which ones have been changed. I know you
can check if the anything in the entire form has been changed by using "if
me.dirty = true then". However, if that is true I somehow need to check each
control individually for changes because the user needs to know each specific
change. Anyways, is there an easier way to check each control for changes
instead of doing
me.control1.dirty
me.control2.dirty
me.control3.dirty
and so on.....
That's what I was planning on doing, but I was hoping someone would know an
easier way.

Thank you in advance,
Alex
 
R

Rick Brandt

Alex said:
Hi,
I have a form with 45-60 controls, a mix of checkboxes, textboxes, and
comboboxes. My users would like to have a continuous historical record of
changes to each record on the form. Is there an easy way to cycle or loop
through each of the controls to see which ones have been changed. I know you
can check if the anything in the entire form has been changed by using "if
me.dirty = true then". However, if that is true I somehow need to check each
control individually for changes because the user needs to know each specific
change. Anyways, is there an easier way to check each control for changes
instead of doing
me.control1.dirty
me.control2.dirty
me.control3.dirty
and so on.....
That's what I was planning on doing, but I was hoping someone would know an
easier way.

Compare each control's Value property to its OldValue property in the form's
BeforeUpdate event.
 
G

Guest

Hi,
Thank you for your response. Can you please elaborate a little bit, I'm
unfamiliar with the BeforeUpdate event. Also, with this method do I have to
check the Old Value in each control?
 
R

Rick Brandt

Alex said:
Hi,
Thank you for your response. Can you please elaborate a little bit, I'm
unfamiliar with the BeforeUpdate event. Also, with this method do I have to
check the Old Value in each control?

The BeforeUpdate of the form fires just before a record is committed to disk.
If you select the form in design view and look at the Events tab of the property
sheet you should see it.

Yes you would loop through all bound controls and any where the Value is not the
same as OldValue have been updated.
 
G

Guest

Ok, the BeforeUpdate event seems like the best way to go. Just one more
thing. I was hoping to find a way that would let me go through each control
without actually typing out the full name of each control. Some of these
controls have really long names so it would be a real pain to have to type
out each control seperately and do this 45 times. Is there a way i can
actually use a loop to cycle through all the controls with minimal amount of
code, like somehow setup an array containing each control. I'm trying to make
this efficient and easy to read for anyone that would have to update the code
after me.

Thank you for the help.
 

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

Similar Threads

Dirty Me 6
Help with Me.Dirty 2
Update controls programmatically 3
how to find subforms not dirty ... 1
Form Dirty 2
Form Dirty Property 1
When does record become dirty? 10
Is Dirty for a field? 3

Top