Dirty propert reset

S

Steve

I have a form that I load default values when a new
record is selected. I reset the dirty property (Me.Dirty
= False)after default values are loaded.

Since there are some required fields on the form I
validate using the form afterupdate event. If there are
no changes made by the user and they attempt to move to a
previous record the Me.Dirty property rather then having
a value of FALSE as it was set for the new record still
has a value of TRUE. In the mean time I will brute force
this by checking if any of the fields on the form have
changed since they were initialized.

Can you reset the Form dirty property from a VB
application if so any ideas on trouble shooting?

Thanks Steve
 
R

Rick Brandt

Steve said:
I have a form that I load default values when a new
record is selected. I reset the dirty property (Me.Dirty
= False)after default values are loaded.

Since there are some required fields on the form I
validate using the form afterupdate event. If there are
no changes made by the user and they attempt to move to a
previous record the Me.Dirty property rather then having
a value of FALSE as it was set for the new record still
has a value of TRUE. In the mean time I will brute force
this by checking if any of the fields on the form have
changed since they were initialized.

Can you reset the Form dirty property from a VB
application if so any ideas on trouble shooting?

You're doing a few things wrong here.

There is a fundamental difference between using Default Values and having your
code set values when navigating to a new record. Default values "don't count"
with respect to record creation whereas a value set in code does.


Setting the Dirty property to false saves the record along with any changes that
have been made. If you are setting values in code and then setting Dirty =
False you are creating a record.


Also, you should be doing validation in the BeforeUpdate event (which can be
cancelled). The AfterUpdate event is too late (it's AFTER the record has
already been saved).
 
S

steve

Long night, I do vaildate on the beforeupdate event. WRT
default values, I assume that the default value will
supplied when ever a new record is created but it will
not set the dirty property, and my life is good again.

Thanks Steve.
 

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

Similar Threads


Top