Dirty

  • Thread starter Thread starter PeterM
  • Start date Start date
P

PeterM

I have a form that edits records in a table. Very basic. I have code in the
Form_Dirty event that sets the delete button to not enabled...
Me.BTN_Delete.Enabled = False

As I understand it, when data on the form is changed, Access fires the
Form_Dirty to True therefore un-enabling the delete button.

It does not work. I'm using AC2003.

Am I forgetting something? thanks for the help.
 
I used something similar recently.
It went like this

Private Sub Form_Dirty(Cancel As Integer)
On Error GoTo Err_Handler
'tested
Me.cmdDelete.Enabled = True

Exit_Handler:
Exit Sub
Err_Handler:
Msgbox Err.Number & " " & Err.Description
Resume Exit_Handler
End Sub


I wanted to enable the delete button only when there was something to
delete.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Very similar to what I have except I disable the delete button when the user
changes the form.

My problem is that when the user changes the form it's not executing the
form_dirty event.
 
Are you saying that if you use this code

Private Sub Form_Dirty(Cancel As Integer)
On Error GoTo Err_Handler

Me.cmdDelete.Enabled = False

Exit_Handler:
Exit Sub
Err_Handler:
Msgbox Err.Number & " " & Err.Description
Resume Exit_Handler
End Sub


that it doesn't work?

I test it by putting a msgbox on the dirty event.
Like this

Private Sub Form_Dirty(Cancel As Integer)
Msgbox "dirty now"
End Sub

Now open your form and enter data.
You should find that the msgbox appears as soon as you do something to make
the form dirty.
Perhaps your code sets a value somewhere in the load event and the form is
already dirty by the time it opens?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
I just checked and all of the controls on the form are bound to the table.
Any other ideas?
 
PeterM said:
I have a form that edits records in a table. Very basic. I have code in
the
Form_Dirty event that sets the delete button to not enabled...
Me.BTN_Delete.Enabled = False

As I understand it, when data on the form is changed, Access fires the
Form_Dirty to True therefore un-enabling the delete button.

It does not work. I'm using AC2003.

Am I forgetting something? thanks for the help.
 
I discovered that on the form_current event, I was changing a value on the
form which triggered the dirty event which meant that when the form opened
the form was already dirty. I added a me.form.dirty = false statement at the
end of the current event and that cleared it up.

Thanks for your help!
 
I discovered that on the form_current event, I was changing a value on the
form which triggered the dirty event which meant that when the form opened
the form was already dirty. I added a me.form.dirty = false statement at the
end of the current event and that cleared it up.

Thanks for your help!
 
Back
Top