Access XP Load and Dirty events

  • Thread starter Patrick McGuire
  • Start date
P

Patrick McGuire

I have a form which opens another form, passing data to
the new form via the OpenArgs parameter of the Form.Open
method. My problem is that when I use the OpenArgs to
populate fields in the new form, I end up having problems
down the road with the Dirty event. After loading in this
way, user edits to fields on the new form do not result in
the Dirty event firing.

Is this a bug or a feature? :) And how do I best code
around this behavior?

Thanks.

Pat
 
A

Albert D. Kallal

According to the help, controls and data modified by code do NOT trigger the
onDirty event. I believe the on-insert does get fired...but only for new
records.

However, your code that just modified those values can certainly thus call
the same routine or code that the on-dirty event would call anyway...right?
So, you *do* in fact know that the record is being modified anyway, and that
code can thus take appropriate action.
 
P

Patrick McGuire

The problem isn't actually that programmatically inserted
data doesn't fire the Dirty event. The problem is that
after the insertion, user actions that otherwise WOULD and
SHOULD fire the Dirty event no longer do so.

Pat
 
P

Patrick McGuire

I just discovered that this behavior occurs when you
populate fields programmatically in the Load event, but
not when you do it in the Open event.

Pat
 
R

Rick Brandt

Patrick McGuire said:
The problem isn't actually that programmatically inserted
data doesn't fire the Dirty event. The problem is that
after the insertion, user actions that otherwise WOULD and
SHOULD fire the Dirty event no longer do so.

I see the same thing in A97 with BeforeInsert. If the very first entry is
done manually with the keyboard or mouse, then the BeforeInsert fires. If
the very first entry is made in code then not only does BeforeInsert not
fire at that point, but it NEVER fires for that record.
 
M

Marshall Barton

Patrick said:
I have a form which opens another form, passing data to
the new form via the OpenArgs parameter of the Form.Open
method. My problem is that when I use the OpenArgs to
populate fields in the new form, I end up having problems
down the road with the Dirty event. After loading in this
way, user edits to fields on the new form do not result in
the Dirty event firing.

Is this a bug or a feature? :) And how do I best code
around this behavior?

Whether it's a bug or a feature, it's by design and
consistent with the way other events are handled.

If you are only doing this to add new records, then you may
want to consider setting those control's DefaultValue
property instead of setting their Value.
 
A

Albert D. Kallal

Ah, ok. Then try just putting a me.Refresh right after your code that
modifies the data. At this point, then any user interaction that modifies
the data should fire the onDirty.

As for using the on-open event? You can look at control values, but you
certainly can't modify them.

However, if you are talking about code that modifies the data NOT by the
form, then that could even be another user...and for sure the on-Ditry event
does not (and should not) fire.

So, if you are modifying the value of controls via code (has to be on-load
or later), then just place me.refresh to force a disk write.
 

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