me.dirty question

G

Guest

What are the rules when using .dirty?

I have a form that is bound to a table. Right now, if I make changes to the
table through the form, it is not always recognized as "dirty". Do I need to
move off the record, save the changes, move to a new row on the table... I
can't seem to figure out what the rules are to make my results consistant.
To test my logic.. I'm still using message boxes... I hit a button on the
form with a simple:

If Forms("frmCSInputs").Dirty = True Then

msgbox "Records have been changed.", vbOKOnly + vbInformation,
"Changed"
Exit Function

Else

msgbox "No record were changed.", vbOKOnly + vbInformation, "No
Records Changed"
Exit Function

End If
 
A

Allen Browne

The form will be Dirty if you have edited any of the *bound* controls.

Editing unbound controls will not dirty the form.
 
G

Guest

Allen,

I thought that is how it's supposed to work... but it's not always
working?!? I can't figure out a pattern on why it's not working.

Does it matter if I save the form, move off the edited bound control...
What could be making it not always work?

Thanks,
 
G

Guest

If you change a bound field then the record is dirty. If you save the record
then the form is no longer dirty. You have to check to see if the form is
dirty prior to saving the record.
 
G

Guest

try to insert the code you mentioned in the event procedure FORM BEFORE
UPDATE(cancel)
you can prevent storing changed records by inserting the code
cancel = true
exit sub

regards Peter
 
G

Guest

What's not clear is how the data is changed? If it is changed by the user
via the GUI, then I can't help with this question. But if the data is
changed programmatically then you have the same problem I experienced.

In Access Help under "Dirty Event" you will find the following:
-modifying a record within a form by using a macro or Visual Basic doesn't
trigger this event. You must type the data directly into the record or set
the control's Text property.

Hope this helps.
Fritz Kiessling
kdsdata
 

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