Detect changes to controls on forms
Moderator: Rathinagiri
Detect changes to controls on forms
I have a form with many fields and controls.
I would like to have the user notified if changes were made and not saved.
eg: MsgYesNo("Changes not saved. Save them now")
I could use the ONCHANGE property and change a trigger variable.
However I'm looking for a simple way.
--Russ
I would like to have the user notified if changes were made and not saved.
eg: MsgYesNo("Changes not saved. Save them now")
I could use the ONCHANGE property and change a trigger variable.
However I'm looking for a simple way.
--Russ
Re: Detect changes to controls on forms
Maybe you can use:I have a form with many fields and controls.
DEFINE TEXTBOX <Controlname>
PARENT <ParentWindowName>
ROW <nValue>
COL <nValue>
HEIGHT <nHeight>
FIELD <FieldName> // Field of DBF
.....
On CHANGE <WindowName>.<ControlName>.Save
and you forget the message ( you can disturb the user with many posts )
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Detect changes to controls on forms
1. Save the initial values of all the controls in an array.
2. When the user tries to release the window ( on release event) try to check the current values of all the controls and the values in the initial array. If nothing is changed, we can release the window. Otherwise, we can show the message to save.
3. You can use a timer also ( say for every 5 seconds ) to either notify the user to save or automatically save only the changed values.
2. When the user tries to release the window ( on release event) try to check the current values of all the controls and the values in the initial array. If nothing is changed, we can release the window. Otherwise, we can show the message to save.
3. You can use a timer also ( say for every 5 seconds ) to either notify the user to save or automatically save only the changed values.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- serge_girard
- Posts: 3176
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Detect changes to controls on forms
Russ,
I agree with Rathi for his points 1 & 2.
It is a bit more complicated but works fine (at least for me!)
Serge
I agree with Rathi for his points 1 & 2.
It is a bit more complicated but works fine (at least for me!)
Serge
There's nothing you can do that can't be done...
Re: Detect changes to controls on forms
All good solutions. My form is populated with variables from dbf fields scattered to input variables (from old clip code)
During the form INIT I set a variable lChanged to .f.
Then on each field I used the ONCHANGE lChanged:=.t.
When exiting the form, if lChanged=.t. I call my save function.
Simple and works.
Additionally, I used the ONCHANGE to set my original variable to the new value
eg: ONCHANGE (lChanged:=.t., _fname:=myform.fname.value)
I also did this because I couldn't figure out how to make my SAVEVARS() function work with the form value.
Was actually easier because I didn't have to rewrite clip code.
How come this gives me a compiler error?
FUNC SAVEVARS()
REPLACE mydbf->fname with myform.fname.value
So now I use original clip code and rely on ONCHANGE to set the var _fname back to what the VALUE clause was initialized with.
REPLACE mydbf->fname with _fname
--Russ
During the form INIT I set a variable lChanged to .f.
Then on each field I used the ONCHANGE lChanged:=.t.
When exiting the form, if lChanged=.t. I call my save function.
Simple and works.
Additionally, I used the ONCHANGE to set my original variable to the new value
eg: ONCHANGE (lChanged:=.t., _fname:=myform.fname.value)
I also did this because I couldn't figure out how to make my SAVEVARS() function work with the form value.
Was actually easier because I didn't have to rewrite clip code.
How come this gives me a compiler error?
FUNC SAVEVARS()
REPLACE mydbf->fname with myform.fname.value
So now I use original clip code and rely on ONCHANGE to set the var _fname back to what the VALUE clause was initialized with.
REPLACE mydbf->fname with _fname
--Russ
- serge_girard
- Posts: 3176
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Detect changes to controls on forms
Russ,
Which compile error are you getting?
Serge
Which compile error are you getting?
Serge
There's nothing you can do that can't be done...
Re: Detect changes to controls on forms
Line of code is:serge_girard wrote:Russ,
Which compile error are you getting?
Serge
replace client->lname with clientinfo.lname.value
clientinfo is my form window name
lname is a text box
client->lname is a character dbf field
Error is:
Harbour: C:\SOURCE\umisc.prg(173) Error E0030 Syntax error Syntax error "syntax error at '.'
I'm a noob at Harbour and don't have much experience here.
--Russ
-
- Posts: 245
- Joined: Sat Aug 02, 2008 5:03 pm
Re: Detect changes to controls on forms
Hi try replacing clientinfo.lname.value with GetProperty( "lname", "clientinfo", "value" )RussBaker wrote: Line of code is:
replace client->lname with clientinfo.lname.value
or
xVar := clientinfo.lname.value
replace client->lname with xVar
Regards/Saludos, Carlos (bcd12a)
Re: Detect changes to controls on forms
Thanks for the tips.Carlos Britos wrote:Hi try replacing clientinfo.lname.value with GetProperty( "lname", "clientinfo", "value" )RussBaker wrote: Line of code is:
replace client->lname with clientinfo.lname.value
or
xVar := clientinfo.lname.value
replace client->lname with xVar
What I essentially did was this method
xVar := clientinfo.lname.value
Using the ONCHANGE to set the variable xVar
It appears you cannot replace a dbf field directly with a form value.
- dragancesu
- Posts: 925
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Detect changes to controls on forms
Clipper has a function UPDATED(), HMG doing a much better and has control ON CHANGE
My solution to the problem is to after last fields on the screen jumps to the SAVE button and one press ENTER solves the problem
My solution to the problem is to after last fields on the screen jumps to the SAVE button and one press ENTER solves the problem
- Attachments
-
- test.zip
- (14.72 KiB) Downloaded 265 times