Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 3 of 3 total |
Locate |
Mon, Feb 21 2011 8:50 PM | Permanent Link |
AlanL | Hello,
Is there a way to display the progress when running e.g. Query1.Locate('Upc',edtSearch.Text, [loCaseInsensitive, loPartialKey]); I am using v4.26 build 3 Many thanks, AlanL |
Tue, Feb 22 2011 4:24 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | AlanL
If it takes long enough for it to be worthwhile displaying progress you have a problem. Things that can be done that might help 1. Make sure the necessary indices are in place 2. Since you're using the contents of an edit I assume you're firing off the search after each key press. If so switch to using a timer. In the on change for the edit disable and enable the timer (ie start it counting again). Put the .Locate code in the timer's event, Set the timers interval to c150. Here's one of mine procedure TContactsForm.DoFindTimer(Sender: TObject); begin DoFind.Enabled := False; if (Finder.Text <> '') and (Finder.Text[Length(Finder.Text)] <> ',') then begin if Finder.Text[1] in ['0'..'9'] then begin Contacts.Locate('_ID', StrToInt(Finder.Text), []); end else begin if (0 = Pos(',', Finder.Text)) then begin Contacts.Locate('_Surname', Finder.Text, [loCaseInsensitive, loPartialKey]); end else begin if not Contacts.Locate('_Surname;_Forename', VarArrayOf([SubFld(Finder.Text, ',', 1), SubFld(Finder.Text, ',', 2)]), [loCaseInsensitive, loPartialKey]) then begin ComplexFind.Close; complexfind.RequestPlan := true; if not ComplexFind.Prepared then ComplexFind.Prepare; ComplexFind.ParamByName(F_Surname).AsString := SubFld(Finder.Text, ',', 1) + '%'; ComplexFind.ParamByName(F_Forename).AsString := SubFld(Finder.Text, ',', 2) + '%'; ComplexFind.ExecSQL; if ComplexFind.RecordCount > 0 then begin ComplexFind.First; Contacts.Locate('_ID', ComplexFind.Fields[0].AsInteger, []); end; ComplexFind.Close; end; end; end; end; end; Roy Lambert [Team Elevate] |
Wed, Feb 23 2011 9:07 PM | Permanent Link |
AlanL | Roy Lambert wrote:
AlanL If it takes long enough for it to be worthwhile displaying progress you have a problem. Things that can be done that might help 1. Make sure the necessary indices are in place 2. Since you're using the contents of an edit I assume you're firing off the search after each key press. If so switch to using a timer. In the on change for the edit disable and enable the timer (ie start it counting again). Put the .Locate code in the timer's event, Set the timers interval to c150. Here's one of mine procedure TContactsForm.DoFindTimer(Sender: TObject); begin DoFind.Enabled := False; if (Finder.Text <> '') and (Finder.Text[Length(Finder.Text)] <> ',') then begin if Finder.Text[1] in ['0'..'9'] then begin Contacts.Locate('_ID', StrToInt(Finder.Text), []); end else begin if (0 = Pos(',', Finder.Text)) then begin Contacts.Locate('_Surname', Finder.Text, [loCaseInsensitive, loPartialKey]); end else begin if not Contacts.Locate('_Surname;_Forename', VarArrayOf([SubFld(Finder.Text, ',', 1), SubFld(Finder.Text, ',', 2)]), [loCaseInsensitive, loPartialKey]) then begin ComplexFind.Close; complexfind.RequestPlan := true; if not ComplexFind.Prepared then ComplexFind.Prepare; ComplexFind.ParamByName(F_Surname).AsString := SubFld(Finder.Text, ',', 1) + '%'; ComplexFind.ParamByName(F_Forename).AsString := SubFld(Finder.Text, ',', 2) + '%'; ComplexFind.ExecSQL; if ComplexFind.RecordCount > 0 then begin ComplexFind.First; Contacts.Locate('_ID', ComplexFind.Fields[0].AsInteger, []); end; ComplexFind.Close; end; end; end; end; end; Roy Lambert [Team Elevate] ---------------------------------------------------------------------------------- Hello Roy, You are correct. I am searching after each key press. Thank you very much for posting your code. This will help me out. best regards, AlanL |
This web page was last updated on Thursday, April 18, 2024 at 10:42 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |