Error message if the form is dirty

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.
 
A

Allen Browne

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
 

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