Hans L

I have two 'New record' options in an app:


In the resulting editing form, I have a an Undo button with

DO FORM frmpartlist

In option APPEND BLANK, the DELETE works as expected (by me, that is).

In option INSERT INTO {Table] FROM MEMVAR, the inserted record hangs around until I close VFP; when I open VFP and the app again, the record is deleted.

I have buffering on, but it is not used in this case, since in both options, the record is created before the editing form opens (normally, I do it the opposite way -- therefore buffering). But maybe it does have an effect after all

Would be grateful to get some hints about why DELETE in the INSERT INTO option does not work as in the APPEND BLANK option.

Hans L

Re: DELETE works after APPEND but not INSERT

Naomi Nosonovsky

I believe the record is deleted (e.g. marked for deletion, but you should have set deleted on and move out of the record so it would disappear).

Anyway, the correct implementation of UNDO button is TABLEREVERT, e.g. you need to have buffering enabled, then you can either save your chages with tableupdate() or revert them with tablerevert()

Re: DELETE works after APPEND but not INSERT


Delete works with the two and is independant.

If you're using buffering then delete is buffered too. Unless you do a tableupdate() it'd be as if you never did a delete. Depending on buffering mode implicit tableupdate() might take place and hence your illusion of one of them is not working. When you do "append blank" you have already selected the table and go top (go recno() etc) would cause an implicit tableupdate (in the case of row level buffering). In the case of insert it's not clear in your code if you're in correct workarea. Probably not. Try:

delete in "aliasnamehere"

Or: Delete - SQL (caution unlike 'delete' you can delete multiple records if you don't supply primary key info in where clause - IOW: "delete from myTable" is like "delete all" or "zap").

However what you're doing is a little strange. Inserting a record and deleting it for "undo". As Naomi pointed out you could use buffer for that and tablerevert() in the case of an "undo". There is a "physical difference" between the two approaches. With delete approach your table size continue to increase (and other headaches follow on the long run).

Re: DELETE works after APPEND but not INSERT

Hans L

Thank you both for the insights. I tried TableRevert(), and then it works fine.

The reason I use Insert is to use a record that already exists. Couples register for a conference, you enter one spouse's information, and then you copy that record with Insert, and you only need to make a few changes for the second spouse. I have the Undo thee, of course, should I change my mind and not enter the second spouse (because it was not a spouse at all -- which I might not have seen first, but another person altogether on the same registration form but with the same check, e.g. a child with a different name -- not unusual -- and a different address).

In a later version, I will do this differently, so as not to create a record until I have deciced whether to save of undo.

Again, thanks.

Hans L