[DUG] Delphi Digest, Vol 160, Issue 1

Paul Wilson paul at accredo.co.nz
Mon Mar 6 15:47:03 NZDT 2017


You can also use TDataset.Lookup instead of Locate which doesn't reposition you and can return a result field of the primary key and if that primary key value doesn't match that of the row you're on, you have a duplicate.

Cheers,
  Paul.

-----Original Message-----
From: delphi-bounces at listserver.123.net.nz [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Marshland Engineering
Sent: Monday, 6 March 2017 12:29 p.m.
To: delphi at listserver.123.net.nz
Subject: Re: [DUG] Delphi Digest, Vol 160, Issue 1

>DisableControls
>Get bookmark
>try
>  First
>  while not (duplicateFound or EOF) do
>  begin
>     duplicateFound := duplicate check(s)
>     Next
>  end
>
>finally
>  Restore bookmark
>  EnableControls
>end


Thanks the DisableControls is great. There are a lot of cross linked tables and printing forms sometimes took a wile. Using this, it was so fast, I though it had done nothing at all but it did. 

I used this for the duplicate search. 

     if (dm.tblMaster.Locate('RaceNo',eRaceNo.text,[loCaseInsensitive])) and (sMNZID <> dm.tblMasterMNZID.AsString) then begin

The second part is so that it does not find its own instance. 

Thanks Wallace.

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe



More information about the Delphi mailing list