EPUB | CHM | PDF

TPSQLDataset.Methods.Cancel

Top Previous Next

Cancels modifications to the current record if those changes are not yet posted.

Syntax:

procedure Cancel;

Description:

Call Cancel to undo modifications made to one or more fields belonging to the current record. As long as those changes are not already posted to the database, Cancel returns the record to its previous state, and sets the dataset state to dsBrowse.

Typically Cancel is used to back out of changes in response to user request, or in field validation routines that back out illegal field values. The TDBNavigator object contains a Cancel button that triggers a call to Cancel.

Example:

The following fragment prompts the user to confirm changes to a record; if the user clicks Yes, the record is posted to the table, otherwise the changes are cancelled.

if MessageDlg('Update Record?',
               mtConfirmation,
               [mbYes, mbNo], 0) = mrYes then
  PSQLTable1.Post
else
  PSQLTable1.Cancel;