Error message if the form is dirty

  • Thread starter Thread starter shiro
  • Start date Start date
S

shiro

Below is my code on click even of a cmdButton to fire off the before
update even of my form.But it produce error message if the form
is dirty :

'The setting you entered is not valid for this property"

And vba highlights the line "Me.Dirty = False".
If Me.Dirty = True Then
Me.Dirty = False
End If

Why it's happen?How to trap it.
 
You get this message if the attempt to save the record fails.

For example, if you cancel the Form_BeforeUpdate event Access can't save the
record. Or if there is a required field missing, it can't save. When this
happens, the error message indicates that the Dirty property cannot be set
to False. That does not mean you cannot ever set the property; it means that
in this particular case, the attempt to set the property did not succeed.

To trap it, use error handling in the procedure where you try to save the
form like this.

If error handling is new, here's an introduction:
http://allenbrowne.com/ser-23a.html
 
Back
Top