Sorry for this silly question

  • Thread starter Thread starter Guest
  • Start date Start date
To find out, open a code window in Access, and see if you can find Help on
the menu.
 
amiga1200 said:
What is 'Dirty', I believe that it can be used to save changes to a
record

"Dirty" is the name of a property of a bound form. If the form's
current record has been modified but not yet saved, then the form's
Dirty property = True; if not, then the Dirty property = False.

Further, you can use the Dirty property to force a form's record to be
saved. If you set the property to False, then the record will be saved,
if there are no constraints preventing it. The usual way this is done
is with a line of code like this:

If Me.Dirty Then Me.Dirty = False

Why not just this:

Me.Dirty = False

?
It's marginally faster to test if the form is Dirty first, and only set
Dirty = False if the form is in fact Dirty.
 
Thanks Dirk

Dirk Goldgar said:
"Dirty" is the name of a property of a bound form. If the form's
current record has been modified but not yet saved, then the form's
Dirty property = True; if not, then the Dirty property = False.

Further, you can use the Dirty property to force a form's record to be
saved. If you set the property to False, then the record will be saved,
if there are no constraints preventing it. The usual way this is done
is with a line of code like this:

If Me.Dirty Then Me.Dirty = False

Why not just this:

Me.Dirty = False

?
It's marginally faster to test if the form is Dirty first, and only set
Dirty = False if the form is in fact Dirty.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
What is 'Dirty', I believe that it can be used to save changes to a record

A form is "dirtied" as soon as the user makes any change to the data
on the form: that is, if the user were to save the record, there would
have been some change made to the data. (Note that if the user changes
a field's value from 3 to 5, and then changes it back to 3, the form
is still dirty; you can't get clean that easily!)

You can check the Dirty property of a form to see if the user has made
any changes at this point (perhaps in the Click event of a Save Record
button; if the form isn't dirty, you don't need to do anything):

If Me.Dirty Then
<do something>
Else
<do something else, or nothing at all>
End If

Or, more sneakily, you can force Access to save a record to disk by
explicitly setting the Dirty property to False:

Me.Dirty = False


John W. Vinson[MVP]
 
Back
Top