Home All Groups Group Topic Archive Search About

Verify if the editing record has changed

Author
13 Mar 2006 2:38 PM
Tom Bianchi
Hi,

I am using VS2005. I have a form that I use both to insert new records and
modify existing records. I want that if the user tries to close the form,
the application asks the user to save changes only if the record has
actually changed.
The problem is that if I use EndEdit, an existing record that has been
modified becomes "Modified" (that's ok), but a new record after EndEdit
becomes "Added", whether it has been modified by the user or not. And if
some fields are not correct, it isn't possible to do an EndEdit, so I think
that this must be done somewhere before the EndEdit.
Is there a way to do this ?

Thanks,
Tom.

Author
13 Mar 2006 4:30 PM
Marina Levit [MVP]
The DataTable doesn't differentiate between a new record that has been
added, and a new record that has been added and also modified by the user
(i.e. the record does not just have default values).

If you want to be able to differentiate between these two different types of
new records, you need to write your own data source. Otherwise, I imagine
you would have to loop through every field to see whether or not they all
have their default values (user hasn't modified it) or at least one field
has a non-default value (user modified it).

Show quoteHide quote
"Tom Bianchi" <a@b.c> wrote in message
news:uqU1fvqRGHA.1204@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I am using VS2005. I have a form that I use both to insert new records and
> modify existing records. I want that if the user tries to close the form,
> the application asks the user to save changes only if the record has
> actually changed.
> The problem is that if I use EndEdit, an existing record that has been
> modified becomes "Modified" (that's ok), but a new record after EndEdit
> becomes "Added", whether it has been modified by the user or not. And if
> some fields are not correct, it isn't possible to do an EndEdit, so I
> think
> that this must be done somewhere before the EndEdit.
> Is there a way to do this ?
>
> Thanks,
> Tom.
>
>