Discussion:
Form, rowset.canSave ...
(too old to reply)
Ken Mayer [dBVIPS]
2008-12-08 22:54:52 UTC
Permalink
Greetings all ...

I have a form that has a rowset with a canSave event handler, which when
editing or adding rows appears to work properly.

However, because of the way this thing works, the user can click the 'X'
on the titlebar, and close the form in the middle of things, and somehow
manage to bypass the rowset's canSave event. Has anyone seen this
before? If so, what do you do to avoid it?

It's causing some problems for my client's app.

Like usual this is a fairly complex form, I couldn't post it because of
the myriad dependencies and I couldn't post the data (due to
confidentiality issues).

If I set the rowset's "modified" property to true in the form's canClose
event handler, the state property is showing as "1" ...

Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)

TIA --

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Greg Hill
2008-12-08 23:51:01 UTC
Permalink
Post by Ken Mayer [dBVIPS]
Greetings all ...
I have a form that has a rowset with a canSave event handler, which when
editing or adding rows appears to work properly.
However, because of the way this thing works, the user can click the 'X'
on the titlebar, and close the form in the middle of things, and somehow
manage to bypass the rowset's canSave event. Has anyone seen this before?
If so, what do you do to avoid it?
It's causing some problems for my client's app.
Like usual this is a fairly complex form, I couldn't post it because of
the myriad dependencies and I couldn't post the data (due to
confidentiality issues).
If I set the rowset's "modified" property to true in the form's canClose
event handler, the state property is showing as "1" ...
Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)
Ken,
It has been working for me for a long time, on more than one form.
I use both the STATE and the MODIFIED to establish if something has been
changed as follows:

if (this.parent.rowset.modified = true or (this.parent.rowset.state = 1 or
this.parent.rowset.state = 2))
nAns = msgbox('Save Changes?','Changes Were Made',35)
if nAns = 6
// Save routine
return class::Save_onclick()
elseif nAns = 7
form.yourQuery1.rowset.abandon()
return true
elseif nAns = 2
return false
endif
endif
return true

It sounds like the data is getting saved somewhere in the process of closing
before your cansave is processed.
But it would help to see your cansave routine, can you post it?

Greg Hill
Ken Mayer [dBVIPS]
2008-12-09 00:20:03 UTC
Permalink
Post by Greg Hill
Post by Ken Mayer [dBVIPS]
Greetings all ...
I have a form that has a rowset with a canSave event handler, which when
editing or adding rows appears to work properly.
However, because of the way this thing works, the user can click the 'X'
on the titlebar, and close the form in the middle of things, and somehow
manage to bypass the rowset's canSave event. Has anyone seen this before?
If so, what do you do to avoid it?
It's causing some problems for my client's app.
Like usual this is a fairly complex form, I couldn't post it because of
the myriad dependencies and I couldn't post the data (due to
confidentiality issues).
If I set the rowset's "modified" property to true in the form's canClose
event handler, the state property is showing as "1" ...
Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)
Ken,
It has been working for me for a long time, on more than one form.
I use both the STATE and the MODIFIED to establish if something has been
if (this.parent.rowset.modified = true or (this.parent.rowset.state = 1 or
this.parent.rowset.state = 2))
nAns = msgbox('Save Changes?','Changes Were Made',35)
if nAns = 6
// Save routine
return class::Save_onclick()
elseif nAns = 7
form.yourQuery1.rowset.abandon()
return true
elseif nAns = 2
return false
endif
endif
return true
It sounds like the data is getting saved somewhere in the process of closing
before your cansave is processed.
But it would help to see your cansave routine, can you post it?
Yeah. I'm a bit flummoxed. Here's my canSave ... I thought I had all the
bases covered, but ...

function rowset_canSave
/*
This is a data check routine ...
First we do data validation, then
we check to see if we have a duplicate record.
The duplicate record is based on name, and phone
*/
local oForm
oForm = this.parent.parent

try
// Data Validation:
if this.state == 2 or this.state == 3
if empty( this.fields["DateEntered"].value )
msgbox( "Please make sure Date Entered is valid!",;
"Data Validation Error!", 16 )
// today's date
this.fields["DateEntered"].value := date()
oForm.DateEnteredDC.DateEntryfield.setFocus()
return false
endif // empty user ...


if empty( this.fields["Security"].value )
msgbox( "Please select your security code!",;
"Data Validation Error!", 16 )
oForm.SecurityCB.setFocus()
return false
endif // empty user ...

if empty( this.fields["TELEPHONE"].value )
msgbox( "Please enter customer Telephone Number!",;
"Data Validation Error!", 16 )
oForm.DataNB.curSel := 2 // page 2 of notebook
oForm.DataNB.PhoneEF.setFocus()
return false
endif // empty Telephone ...

endif // state == 3

// only check this when appending a new row:
if this.state == 3
// Duplicate Record:
local qTemp, rTemp, fTemp
qTemp = new query()
qTemp.database := oForm.MBI1
qTemp.sql := "select * from addressl"
qTemp.active := true
rTemp = qTemp.rowset
fTemp = rTemp.fields
rTemp.locateOptions := 1 // ignore length

// get values from record buffer
local bFound, cLName, cFName, cPhone, cAddress, cCity
cLName = this.fields["LAST"].value.rightTrim()
cFName = this.fields["FIRST"].value.rightTrim()
cPhone = this.fields["TELEPHONE"].value.rightTrim()


bFound = false
bFound = rTemp.applyLocate( [LAST=']+cLName+[' and ]+;
[FIRST=']+cFName+[' and ]+;
[TELEPHONE=']+cPhone+['] )
do while bFound

if bFound
cAddress = fTemp["Address"].value.rightTrim()
cCity = fTemp["Town"].value.rightTrim()
// ask user if this is really a duplicate?
if msgbox( "Name: "+cFName+" "+cLName+chr(13)+;
"Address: "+cAddress+chr(13)+;
"City: "+cCity+chr(13)+;
"Phone: "+cPhone+chr(13)+chr(13)+;
"Is this a duplicate record?",;
"Possible Duplicate!", 4+32 ) == 6
exit
endif

// if they said "No", then we need to try again:
bFound = rTemp.locateNext()
if not bFound
exit
endif

endif

enddo

// Let them know why we can't save it:
if bFound
msgbox( "Duplicate record found,"+chr(13)+;
"check data, and either"+chr(13)+;
"abandon, or ensure this"+chr(13)+;
"is a new customer.",;
"Duplicate Data", 16 )
return false
endif

endif // state = 3

// deal with saving values back to the various
// mailing lists -- because we are using the code as
// part of the value in the array, this should be
// easier than it might have been otherwise:
local cListValue, oNB
oNB = oForm.DataNB

// AList:
cListValue = oNB.AListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["ALIST"].value := cListValue

// BList:
cListValue = oNB.BListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["BLIST"].value := cListValue

// CList:
cListValue = oNB.CListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["CLIST"].value := cListValue

// DList:
cListValue = oNB.DListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["DLIST"].value := cListValue

// IList:
cListValue = oNB.IListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["ILIST"].value := cListValue

// CompList:
cListValue = oNB.CompListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["COMPLIST"].value := cListValue

// PPTList:
cListValue = oNB.PPTListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["PPTLIST"].value := cListValue

// User:
cListValue = oNB.UserCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
// the code could be longer:
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["USER"].value := cListValue

catch( exception e )
msgbox( "Error in canSave method:"+chr(13)+chr(13)+;
"Error: "+e.code+chr(13)+;
"Message: "+e.message+chr(13)+;
"Line: "+e.lineno,;
"Programmer Error!", 16 )
return false
endtry

return true
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Greg Hill
2008-12-09 04:02:55 UTC
Permalink
Post by Ken Mayer [dBVIPS]
Post by Greg Hill
Post by Ken Mayer [dBVIPS]
Greetings all ...
I have a form that has a rowset with a canSave event handler, which when
editing or adding rows appears to work properly.
However, because of the way this thing works, the user can click the 'X'
on the titlebar, and close the form in the middle of things, and somehow
manage to bypass the rowset's canSave event. Has anyone seen this
before? If so, what do you do to avoid it?
It's causing some problems for my client's app.
Like usual this is a fairly complex form, I couldn't post it because of
the myriad dependencies and I couldn't post the data (due to
confidentiality issues).
If I set the rowset's "modified" property to true in the form's canClose
event handler, the state property is showing as "1" ...
Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)
Ken,
It has been working for me for a long time, on more than one form.
I use both the STATE and the MODIFIED to establish if something has been
if (this.parent.rowset.modified = true or (this.parent.rowset.state = 1
or this.parent.rowset.state = 2))
nAns = msgbox('Save Changes?','Changes Were Made',35)
if nAns = 6
// Save routine
return class::Save_onclick()
elseif nAns = 7
form.yourQuery1.rowset.abandon()
return true
elseif nAns = 2
return false
endif
endif
return true
It sounds like the data is getting saved somewhere in the process of
closing before your cansave is processed.
But it would help to see your cansave routine, can you post it?
Yeah. I'm a bit flummoxed. Here's my canSave ... I thought I had all the
bases covered, but ...
function rowset_canSave
/*
This is a data check routine ...
First we do data validation, then
we check to see if we have a duplicate record.
The duplicate record is based on name, and phone
*/
local oForm
oForm = this.parent.parent
try
if this.state == 2 or this.state == 3
if empty( this.fields["DateEntered"].value )
msgbox( "Please make sure Date Entered is valid!",;
"Data Validation Error!", 16 )
// today's date
this.fields["DateEntered"].value := date()
oForm.DateEnteredDC.DateEntryfield.setFocus()
return false
endif // empty user ...
if empty( this.fields["Security"].value )
msgbox( "Please select your security code!",;
"Data Validation Error!", 16 )
oForm.SecurityCB.setFocus()
return false
endif // empty user ...
if empty( this.fields["TELEPHONE"].value )
msgbox( "Please enter customer Telephone Number!",;
"Data Validation Error!", 16 )
oForm.DataNB.curSel := 2 // page 2 of notebook
oForm.DataNB.PhoneEF.setFocus()
return false
endif // empty Telephone ...
endif // state == 3
if this.state == 3
local qTemp, rTemp, fTemp
qTemp = new query()
qTemp.database := oForm.MBI1
qTemp.sql := "select * from addressl"
qTemp.active := true
rTemp = qTemp.rowset
fTemp = rTemp.fields
rTemp.locateOptions := 1 // ignore length
// get values from record buffer
local bFound, cLName, cFName, cPhone, cAddress, cCity
cLName = this.fields["LAST"].value.rightTrim()
cFName = this.fields["FIRST"].value.rightTrim()
cPhone = this.fields["TELEPHONE"].value.rightTrim()
bFound = false
bFound = rTemp.applyLocate( [LAST=']+cLName+[' and ]+;
[FIRST=']+cFName+[' and ]+;
[TELEPHONE=']+cPhone+['] )
do while bFound
if bFound
cAddress = fTemp["Address"].value.rightTrim()
cCity = fTemp["Town"].value.rightTrim()
// ask user if this is really a duplicate?
if msgbox( "Name: "+cFName+" "+cLName+chr(13)+;
"Address: "+cAddress+chr(13)+;
"City: "+cCity+chr(13)+;
"Phone: "+cPhone+chr(13)+chr(13)+;
"Is this a duplicate record?",;
"Possible Duplicate!", 4+32 ) == 6
exit
endif
bFound = rTemp.locateNext()
if not bFound
exit
endif
endif
enddo
if bFound
msgbox( "Duplicate record found,"+chr(13)+;
"check data, and either"+chr(13)+;
"abandon, or ensure this"+chr(13)+;
"is a new customer.",;
"Duplicate Data", 16 )
return false
endif
endif // state = 3
// deal with saving values back to the various
// mailing lists -- because we are using the code as
// part of the value in the array, this should be
local cListValue, oNB
oNB = oForm.DataNB
cListValue = oNB.AListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["ALIST"].value := cListValue
cListValue = oNB.BListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["BLIST"].value := cListValue
cListValue = oNB.CListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["CLIST"].value := cListValue
cListValue = oNB.DListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["DLIST"].value := cListValue
cListValue = oNB.IListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["ILIST"].value := cListValue
cListValue = oNB.CompListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["COMPLIST"].value := cListValue
cListValue = oNB.PPTListCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["PPTLIST"].value := cListValue
cListValue = oNB.UserCB.value
if not empty( cListValue )
// go to first space, should be 3 characters, but
cListValue = left( cListValue, at( " ", cListValue ) - 1 )
endif
this.fields["USER"].value := cListValue
catch( exception e )
msgbox( "Error in canSave method:"+chr(13)+chr(13)+;
"Error: "+e.code+chr(13)+;
"Message: "+e.message+chr(13)+;
"Line: "+e.lineno,;
"Programmer Error!", 16 )
return false
endtry
return true
All looks good there. One question though, in several places I see
oRef.setFocus(), if there are any onGotFocus routines attached to those
fields, it might be causing a navigation. Also on the DataNB.curSel change,
is there anything attached to that?

Is there a form_onGotFocus that runs, if so it would execute on return from
a MSGBOX.

That is about all I can see off hand.

Maybe those things will help lead to something.

Greg Hill
Lysander
2008-12-09 09:46:42 UTC
Permalink
Post by Ken Mayer [dBVIPS]
However, because of the way this thing works, the user can click the
'X' on the titlebar, and close the form in the middle of things, and
somehow manage to bypass the rowset's canSave event. Has anyone seen
this before? If so, what do you do to avoid it?
For what it's worth, there has been an issue with some update of dBase
that "x"ing a Form would not let the cansave be fired. I don't remember
the details but maybe if you do a search you will find something.

If I remember correctly that was about 2-4 years ago and fixed again in
some later version.

Maybe it came back? Or maybe your client is running that slightly older
version of dBase runtime?
Ken Mayer [dBVIPS]
2008-12-09 13:32:07 UTC
Permalink
Post by Lysander
Post by Ken Mayer [dBVIPS]
However, because of the way this thing works, the user can click the
'X' on the titlebar, and close the form in the middle of things, and
somehow manage to bypass the rowset's canSave event. Has anyone seen
this before? If so, what do you do to avoid it?
For what it's worth, there has been an issue with some update of dBase
that "x"ing a Form would not let the cansave be fired. I don't remember
the details but maybe if you do a search you will find something.
If I remember correctly that was about 2-4 years ago and fixed again in
some later version.
Maybe it came back? Or maybe your client is running that slightly older
version of dBase runtime?
No, he has the latest runtime. I've been careful about that. I am
thinking that somehow or other the data may be being saved. It's very
frustrating tracing things down sometimes, because this code is fairly
complex. (Checking a lot of information ... including hunting down tax
code info, and more ... )

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Glenn
2008-12-09 04:38:29 UTC
Permalink
Post by Ken Mayer [dBVIPS]
Greetings all ...
I have a form that has a rowset with a canSave event handler, which when
editing or adding rows appears to work properly.
However, because of the way this thing works, the user can click the 'X'
on the titlebar, and close the form in the middle of things, and somehow
manage to bypass the rowset's canSave event. Has anyone seen this
before? If so, what do you do to avoid it?
It's causing some problems for my client's app.
Like usual this is a fairly complex form, I couldn't post it because of
the myriad dependencies and I couldn't post the data (due to
confidentiality issues).
If I set the rowset's "modified" property to true in the form's canClose
event handler, the state property is showing as "1" ...
Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)
TIA --
Ken
how about just taking the "x"away ??

Glenn
Ken Mayer [dBVIPS]
2008-12-09 13:32:51 UTC
Permalink
Post by Glenn
Post by Ken Mayer [dBVIPS]
Greetings all ...
I have a form that has a rowset with a canSave event handler, which
when editing or adding rows appears to work properly.
However, because of the way this thing works, the user can click the
'X' on the titlebar, and close the form in the middle of things, and
somehow manage to bypass the rowset's canSave event. Has anyone seen
this before? If so, what do you do to avoid it?
It's causing some problems for my client's app.
Like usual this is a fairly complex form, I couldn't post it because
of the myriad dependencies and I couldn't post the data (due to
confidentiality issues).
If I set the rowset's "modified" property to true in the form's
canClose event handler, the state property is showing as "1" ...
Argh. (I might be able to see this better if I were running on a
full-night's sleep, but I had a nasty bit of insomnia last night.)
TIA --
Ken
how about just taking the "x"away ??
Yeah. I may have to. But then I'll need to add a "close" button
somewhere ... but it may be necessary.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Greg Hill
2008-12-09 18:30:11 UTC
Permalink
There is a simple way to deal with this (if the app design allows), put a
button that puts the form in edit mode and when that button is clicked the
text on it changes or you can use the toggle button.

Then when they click the X you can use the canClose to detect the text on
the button. Obviously if the text show the form is in edit mode then tell
them they have to save or cancel the data before they can exit the form.

Greg Hill
Ken Mayer [dBVIPS]
2008-12-09 22:56:34 UTC
Permalink
Post by Greg Hill
There is a simple way to deal with this (if the app design allows), put a
button that puts the form in edit mode and when that button is clicked the
text on it changes or you can use the toggle button.
Then when they click the X you can use the canClose to detect the text on
the button. Obviously if the text show the form is in edit mode then tell
them they have to save or cancel the data before they can exit the form.
Gad. Well, I will take a look. It's possible that the solution is more
simple than that, but ... sigh. Very weird. Thanks. The worst part is,
it's probably sitting in front of me and I'm just missing it.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Greg Hill
2008-12-09 23:38:08 UTC
Permalink
Post by Ken Mayer [dBVIPS]
Post by Greg Hill
There is a simple way to deal with this (if the app design allows), put a
button that puts the form in edit mode and when that button is clicked
the text on it changes or you can use the toggle button.
Then when they click the X you can use the canClose to detect the text on
the button. Obviously if the text show the form is in edit mode then
tell them they have to save or cancel the data before they can exit the
form.
Gad. Well, I will take a look. It's possible that the solution is more
simple than that, but ... sigh. Very weird. Thanks. The worst part is,
it's probably sitting in front of me and I'm just missing it.
Something I like to do is to put a msgbox("hello"), in the onNavigate of the
rowset :-)

It reveals some interesting stuff sometimes.

Greg Hill
Ken Mayer [dBVIPS]
2008-12-10 05:03:56 UTC
Permalink
Post by Greg Hill
Post by Ken Mayer [dBVIPS]
Post by Greg Hill
There is a simple way to deal with this (if the app design allows), put a
button that puts the form in edit mode and when that button is clicked
the text on it changes or you can use the toggle button.
Then when they click the X you can use the canClose to detect the text on
the button. Obviously if the text show the form is in edit mode then
tell them they have to save or cancel the data before they can exit the
form.
Gad. Well, I will take a look. It's possible that the solution is more
simple than that, but ... sigh. Very weird. Thanks. The worst part is,
it's probably sitting in front of me and I'm just missing it.
Something I like to do is to put a msgbox("hello"), in the onNavigate of the
rowset :-)
It reveals some interesting stuff sometimes.
Yeah. The sequence of event firing can be ... very interesting
(sometimes in a surprising way).

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Jan Hoelterling
2008-12-09 14:23:39 UTC
Permalink
Hi Ken,

have you thought about adding a canClose event to check for state and
modified? In it, call your canSave.

In my forms, I always have an "OK" button, so I interpret the "X" as cancel.
In my base form class, I have:

function form_canclose
mCC = true
if form.hasrowset
if form.rowset.state>1
if msgbox("Are you sure you want to cancel without
saving?","Please confirm",32+4) = 6
form.rowset.abandon()
else
mCC = false
endif
endif
endif
if mCC
// cleanup various stuff
endif
return(mcc)

Also, instead of canSave, I use canNavigate - it seems to do the job well.

HTH,

Jan
Ken Mayer [dBVIPS]
2008-12-09 22:58:37 UTC
Permalink
Post by Jan Hoelterling
Hi Ken,
have you thought about adding a canClose event to check for state and
modified? In it, call your canSave.
In my forms, I always have an "OK" button, so I interpret the "X" as cancel.
function form_canclose
mCC = true
if form.hasrowset
if form.rowset.state>1
if msgbox("Are you sure you want to cancel without
saving?","Please confirm",32+4) = 6
form.rowset.abandon()
else
mCC = false
endif
endif
endif
if mCC
// cleanup various stuff
endif
return(mcc)
Also, instead of canSave, I use canNavigate - it seems to do the job well.
Hmm. Well, I have something *like* that in the custom form this one is
derived from. But I think something isn't happening somewhere, or
something is that shouldn't ... but I may have to disable the "X" (easy
enough), and force the form to close through a pushbutton.

The frustrating thing is that I was re-using code, rather than trying to
have a separate form for finding the customers (in this case), so I have
one for editing and finding customers, which has the advantage of
allowing a new customer to be entered from the Quote screen, or an
existing customer's data to be modified. But something is not stopping
the customer form from closing properly.

Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
http://www.goldenstag.net/dbase
Loading...