Data.DB.TDataSet.FindLast

From RAD Studio API Documentation
Jump to: navigation, search

[–] Properties
Type: function
Visibility: public
Source:
Data.DB.pas
Data.DB.hpp
Unit: Data.DB
Parent: TDataSet

Delphi

function FindLast: Boolean;

C++

bool __fastcall FindLast();

Description

Implements a virtual method for positioning the dataset on the last record, respecting any filters.

FindLast is intended to be used together with FindPrior, FindFirst and FindNext in order to search for the last record using any filters. See the example.

Notes:

Descendant classes override FindLast to make the last record active, honoring any filters that are in effect. In descendants, FindLast returns true:

  • True -- if the active record is successfully changed.
  • False -- if the active record is not successfully changed.

Example

Here is a code snippet that shows how to use FindLast and FindPrior to search for a record using a filtering expression:

Delphi:

FDQuery1.Filter := 'amount >= 10000';
if FDQuery1.FindLast then
   repeat
    // do something
   until not FDQuery1.FindPrior;

C++:

FDQuery1->Filter="amount >= 10000";
if (FDQuery1->FindLast()){
   do {
    // do something
   }
   while (FDQuery1->FindPrior());
}

See Also