OnDirty Doesn't seem to be working

C

charles.kendricks

I have a form which I use to bring up client records and if necessary
make changes to them. I also have a log table which I want to update
only when changed to a client record is made. I have tied an append
query to the AfterUpdate event of the form, but it updates the table
even when no change is made to a client record. When I tie the append
query to the OnDirty even of the form it doesn't seem to run at all.
In fact I placed a Debug.Print statement in the OnDrity event, then
open the form to a client record and make changes to the phone number,
expecting to see my Debug message in the immediate window as soon at
the data on the form is changed, and nothing happens. Am I mis-
understanding something???
 
D

Dirk Goldgar

In
I have a form which I use to bring up client records and if necessary
make changes to them. I also have a log table which I want to update
only when changed to a client record is made. I have tied an append
query to the AfterUpdate event of the form, but it updates the table
even when no change is made to a client record.

If the AfterUpdate is firing, the record must have been changed.
When I tie the append
query to the OnDirty even of the form it doesn't seem to run at all.
In fact I placed a Debug.Print statement in the OnDrity event, then
open the form to a client record and make changes to the phone number,
expecting to see my Debug message in the immediate window as soon at
the data on the form is changed, and nothing happens. Am I mis-
understanding something???

The combination of these two observations -- AfterUpdate event fires
even though you didn't modify the record via the user interface; Dirty
event (not "OnDirty" event) doesn't fire even when you do modify the
record -- strongly suggests that you have code that is modifying the
record, possibly in the form's Current event. When a record is modified
by code, the Dirty event doesn't fire. If you do that and subsequently
modify the now-dirty record manually, the Dirty event still doesn't fire
(because the record is already dirty). The Dirty event only fires when
the record is first dirtied by the user, not by code.

So check the other form events, especially the Current event, to see if
you have code that is modifying the record.
 
C

charles.kendricks

In


If the AfterUpdate is firing, the record must have been changed.


The combination of these two observations -- AfterUpdate event fires
even though you didn't modify the record via the user interface; Dirty
event (not "OnDirty" event) doesn't fire even when you do modify the
record -- strongly suggests that you have code that is modifying the
record, possibly in the form's Current event. When a record is modified
by code, the Dirty event doesn't fire. If you do that and subsequently
modify the now-dirty record manually, the Dirty event still doesn't fire
(because the record is already dirty). The Dirty event only fires when
the record is first dirtied by the user, not by code.

So check the other form events, especially the Current event, to see if
you have code that is modifying the record.

Dirk

You were 100% correct in your analysis...I was able to move the
defaults that were set in the Current event and now I can detect
changes just as I hoped...Thanks

Charles
 

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