PlanetSquires Forums

Support Forums => General Board => Topic started by: Marc van Cauwenberghe on May 17, 2012, 07:39:24 AM

Title: save trigger
Post by: Marc van Cauwenberghe on May 17, 2012, 07:39:24 AM
Hi,

I would like to know how anyone programs the saving of records once the dataentry is done or some editing have been done in the dataentry form.
My aim is to not have to save a record if nothing has changed.
I have used several methods in the past years. Setting a so called 'IsDirty' flag if one edited a field, comparing fields, ...
I now use the following:
When I retrieve a record form possible editing, I put record in a type, e.g. UserType and then use that to fill the fields.
When  someone clicked save I put the fields in an other type e.g. UserFormType.
I then compare the 2 Types.

Any comments, suggestions?

Thanks,
Marc

Title: Re: save trigger
Post by: Rolf Brandt on May 17, 2012, 09:02:14 AM
I usually check change event of controls. Whenever a change occurred I enable the save button, otherwise it stays disabled.

But your way of comparison sounds very good to me.


Rolf
Title: Re: save trigger
Post by: Marc van Cauwenberghe on May 17, 2012, 09:38:24 AM
Thank you Rolf,

So your checking for the EN_CHANGE event. Am I correct in thinking that if one makes a change and then undoes his edit this would be still have triggered the EN_CHANGE so setting the what I like to call the 'IsDirty' flag. I could off course combine the 2 and just do a type compare if a EN_CHANGE event was triggered in one of the fields.

Thanks and have a nice day.
Marc
Title: Re: save trigger
Post by: Paul Squires on May 17, 2012, 01:32:12 PM
One word of caution, if you are depending on EN_CHANGE you should realize that message will fire when your Form is first created. This is because FF will assign text to the edit control after it is initially created in WM_CREATE. We have discussed this in this forum in the past and the technique to use is to set a global flag that is tested in EN_CHANGE and, if FALSE, do not process the EN_CHANGE notification. You set this global variable to TRUE at the end of your WM_CREATE message handler for your Form so subsequent EN_CHANGE notifications will be caught.

Let me look for a past post on this.....

(Edit)
Check out this post:  http://www.planetsquires.com/protect/forum/index.php?topic=2502.msg19167#msg19167
Title: Re: save trigger
Post by: Nathan Durland on May 24, 2012, 03:49:45 PM
I do something similar.  There's a global gFormIsDirty that I set %True in EN_CHANGE.  The last line in FORM_CREATE is gFormIsDirty = %False.  It is also set %False after a save, at form unload, etc.
Title: Re: save trigger
Post by: Marc van Cauwenberghe on May 25, 2012, 08:18:23 AM
Thank you Nathan.