Discussion:
rowset.onsave event
(too old to reply)
Glenn Johansen
2008-11-14 19:02:06 UTC
Permalink
If I use the onsave event to make some changes to the "row that was just
saved" do I have to turn off ( null out ) the onsave event then set it back
on?

- glenn
Ken Mayer [dBVIPS]
2008-11-14 21:02:20 UTC
Permalink
Post by Glenn Johansen
If I use the onsave event to make some changes to the "row that was just
saved" do I have to turn off ( null out ) the onsave event then set it back
on?
Um ... I would suggest perhaps using canSave instead, how's that?

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
Bruce R. Roland
2008-11-15 10:56:48 UTC
Permalink
Post by Glenn Johansen
If I use the onsave event to make some changes to the "row that was just
saved" do I have to turn off ( null out ) the onsave event then set it back
on?
- glenn
Glenn

I am not sure if I fully understand what you are doing here but FWIW ONSAVE will only fire if there was actual data changed in the recod. If no data was changed then it will not fire.

For example, I use a routine which alters the behavior and appearance of my forms when entering the edit mode. After editing is copmpleted (Data modified) the Onsave event fires and alters the look and behavior of my forms back to what it was before entering edit. This works well "if there was an actual change to the data" made.

The problem I ran into was when someone entered the edit mode but then never actually made any changes to the data before exiting edit. In that case ONSAVE never fired because the data was not modified.

Onsave looks at Modified before firing. If" Modified = false" (data was not changed) Onsave will not fire and thus will not save the record or run any associated code.

The solution I found was to force Onsave to fire regardless of whether the data was saved or not, thus, running the associated code whether the data was saved or not. This was easy to do by simply ensuring "modified" is set to "true" before exiting the edit mode (added line "Modified = true" to the end of my edit routine) thus fooling Onsave into thinking the data was changed and firing even if it wasn't.

I don't know if this helps, but there it is ....

Bruce

Loading...