[Solved] Cancel insert row
Posted: Thu Jul 31, 2008 11:18 pm
Is it possible to cancel inserting a new record in base? I use the following code which works well for records which haven't changed and records which have to be updated:
The oForm.deleteRow() doesn't work as this may not be used when in new records. oForm.cancelRowUpdates works only on pre-existing records (function sequence error). Perhaps I should first save the current record and then delete it right away? But apparantly this doesn't work either?
or even simpler
Does anyone have a tip to get this working?
Code: Select all
if NOT oForm.IsModified() then 'no modifications to record, only works on pre-existing records
iAnswer = 6
else
iAnswer=MsgBox("Wijzigingen opheffen?",51,"gegevens gewijzigd") 'record is modified, ask to cancel changes.
end if
if iAnswer = 6 then 'cancel saving to database
if (oForm.isNew) then 'if in insert-row (new record chosen)
oForm.deleteRow() 'cancelrowupdates only works for pre-existing records, how do I do this?
else 'not in new mode means in edit mode
oForm.cancelRowUpdates() 'cancel changes on pre-existing record works ok
endif
elseif iAnswer = 7 then 'save changes to database
if (oForm.isNew) then oForm.insertRow else oForm.updateRow() 'save to new record or update pre-existing record
else
exit sub ' assume cancel -> don't save changes when in new mode
endif
Code: Select all
if (oForm.isNew) then
bm=oForm.Bookmark
oForm.insertRow()
oForm.absolute(bm)
oForm.deleteRow(bm)
else
oForm.cancelRowUpdates()
endif
Code: Select all
if (oForm.isNew) then
oForm.insertRow()
oForm.deleteRow
else
oForm.cancelRowUpdates()
endif