Finding Records Using an Index


Code below would need a valid Index key to be include or set on the TTabel (IndexName property) that need's to be search upon.


procedure TCustForm.FindCompanyBTClick

(Sender : TObject);

var

        Ok : boolean;

        CompToFind : String;

begin

        CompToFind := '';

        { prompt the user for the company to find }

        Ok := InputQuery('Which company?',

                'Enter the company to find',

                CompToFind);


        if Ok then

           with CustForm do

                with MainData.CustTbl do

                begin                

                { switch to the ByCompany Index }

                IndexName := 'ByCompany';

                FindNearest([CompToFind]);

                end;

end;