how to determine if any controls (data) has changed

T

Tim Zych

Is there a form level way to determine if any data has
changed in a form?

I have about 20 controls on a form. If any data for those
controls have changed, I want to alert the user that the
contents in the form have not been saved yet. This form is
bound to a temp table on the client and the user must
specifically "Save" the contents of the form to the shared
BE.

In the "Save" action (command button), I will change the
status message to "Saved". But if any data is changed
between "Save" actions, I want the status to show "Not
saved yet."

One way around this is to add code to every control's
AfterUpdate and Change event. But I am wondering if there
is a Form level way to do this.

Thanks
 
R

Rick B

Somewhere in code(maybe in the before update event...


If Me.Dirty Then
<insert code here>
End If


Rick B


Is there a form level way to determine if any data has
changed in a form?

I have about 20 controls on a form. If any data for those
controls have changed, I want to alert the user that the
contents in the form have not been saved yet. This form is
bound to a temp table on the client and the user must
specifically "Save" the contents of the form to the shared
BE.

In the "Save" action (command button), I will change the
status message to "Saved". But if any data is changed
between "Save" actions, I want the status to show "Not
saved yet."

One way around this is to add code to every control's
AfterUpdate and Change event. But I am wondering if there
is a Form level way to do this.

Thanks
 
S

somanybugssolittletimetofixthem

I have a similar problem. Does this 'me.dirty' test work with a form consisting of unbound controls?
- david
 
T

Tim Zych

Thanks for responding, but...not seeing how that's even
close to the behavior the AfterUpdate and Change events
produce.

What behavior do you see on your machine? Your suggestion
is triggered if I move to a different record after a
control has been changed. That's extraordinarily different
than the behavior I would like.
 
R

Rick B

I guess I am not following. In a bound form that is tied to a table, the
"dirty" test would determine if any of the control data has been changed.

I must be totally misunderstanding your question.

Sorry.

Rick B




Thanks for responding, but...not seeing how that's even
close to the behavior the AfterUpdate and Change events
produce.

What behavior do you see on your machine? Your suggestion
is triggered if I move to a different record after a
control has been changed. That's extraordinarily different
than the behavior I would like.
 
T

Tim Zych

Ok..so if I have 2 controls on a form, and I change either
of them, I want to update a status message.

The Form_Dirty seems to work but only for the first
instance of a change anywhere. I need to capture any
changes at any time.

So my workaround approach is as follows:

Sub Combobox1_AfterUpdate()
'Status message = "Need to save changes"
End Sub

Sub Combobox2_AfterUpdate()
'Status message = "Need to save changes"
End Sub

Sub CommandSave_Click()
'Status message = "Saved"
End Sub

The form is bound to a temp table. The temp table can
contain one or more rows. Any time the Save action occurs,
that current record is saved to the BE.

This "disconnected" approach allows the user to make a
bunch of changes to their data but not "commit" them until
they explicitly save them.

So if there are a bunch of records being viewed in the
form, and during the course of viewing they only change
one, the status message will tell them which one has to be
saved. This avoids the need to save every single record
even if it has not been changed.

Does that make more sense?
 

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