Dirty event does not fire

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2003: I want to use the Form_Dirty event, but find it is not firing.
I have checked all the help pages and searched all over the net.
The form IS a bound form.
Any suggestions?
 
Richard Wright said:
Access 2003: I want to use the Form_Dirty event, but find it is not
firing. I have checked all the help pages and searched all over the
net.
The form IS a bound form.
Any suggestions?

First questions:

1. What are you doing to make it fire?

2. How do you know it's not firing?
 
I expect it to fire when typing into controls, selecting from combos and
changing to another tab on my multi tab form.

I know its not firing because the properties of a couple of buttons are not
changeing as expected. These are set in the standard sub: Private Sub
Form_Dirty(Cancel As Integer).

(the OnDirty property of the form is correctly set to [Event Procedure] so
I'm flumuxed!)

regards
Richard
 
Richard Wright said:
I expect it to fire when typing into controls, selecting from combos
and changing to another tab on my multi tab form.

I know its not firing because the properties of a couple of buttons
are not changeing as expected. These are set in the standard sub:
Private Sub Form_Dirty(Cancel As Integer).

(the OnDirty property of the form is correctly set to [Event
Procedure] so I'm flumuxed!)

I wouldn't expect the Dirty event to fire just because you change from
one tab page to another. It should fire when you type into controls or
select from combo boxes, though, provided that those controls are bound.

Set a breakpoint on the Form_Dirty event procedure, then go to form view
and do something that should dirty the form. If code stops at the
breakpoint, you'll know that the event is being raised. Then you can
step through the code and see if the code's execution path differs from
what you'd expect. That would be something else to debug.
 
Thanks for your help Dirk.
The Form_Dirty event wasn't firing because I had code in the Form_Activate
event that set the value of one the text boxes on the form. I have moved
this code to another event and now it's fine - nice and dirty!

thanks again
regards
Richard

Dirk Goldgar said:
Richard Wright said:
I expect it to fire when typing into controls, selecting from combos
and changing to another tab on my multi tab form.

I know its not firing because the properties of a couple of buttons
are not changeing as expected. These are set in the standard sub:
Private Sub Form_Dirty(Cancel As Integer).

(the OnDirty property of the form is correctly set to [Event
Procedure] so I'm flumuxed!)

I wouldn't expect the Dirty event to fire just because you change from
one tab page to another. It should fire when you type into controls or
select from combo boxes, though, provided that those controls are bound.

Set a breakpoint on the Form_Dirty event procedure, then go to form view
and do something that should dirty the form. If code stops at the
breakpoint, you'll know that the event is being raised. Then you can
step through the code and see if the code's execution path differs from
what you'd expect. That would be something else to debug.

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

(please reply to the newsgroup)
 
Richard Wright said:
Thanks for your help Dirk.
The Form_Dirty event wasn't firing because I had code in the
Form_Activate event that set the value of one the text boxes on the
form. I have moved this code to another event and now it's fine -
nice and dirty!

Oh, yeah. Now that you mention it, I remember that he form's Dirty
event doesn't fire if you have already dirtied it programmatically. It
only fires, as I now recall, if the form becomes dirty as a result of
user action. If the form has already been dirtied by code, that can't
happen.

Sorry, I was late remembering that.
 
I'd be interested to find out what event you moved your code to that would
cause the on dirty event to fire and what version of access you are using.

i have done extensive testing side by side today with access 2000 and access
2003 and have been unable to get an access 2003 forms on dirty event to fire
with vba code (the form is not dirty before the code modifies the data but is
after the data is modified, yet the event does not fire).

It does fire with access 2000 however.
 
Sheesh, how many threads did you start with this question?
It is near impossible to keep track of a train of thought
when it fragmented across multople groups and threads.

I just remembered that there is a way to trigger the usual
events. If you set a text or combo box's Text property
instead of its Value property, the events are triggered the
same as for user input.
 
I just resolved a similar problem. The big key is that the dirty even fires
only when a CONTROL on the form changes data from a table (by user typing,
pasting, or delteteing). This means that any unbound control will not triger
the even. Check to make sure that the control is bound to a table's data
field.
 

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

Back
Top