[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search for record with secondary index.

Posted on 1998-07-28
4
Medium Priority
?
175 Views
Last Modified: 2010-04-04

I use this piece of code (from the Sams book) to search for a record in a db and I get the error message that the dataset is not in edit or insert mode (suppose this is because I use the SetKey command).
Can anybody tell me what's going wrong?



procedure TForm1.btnSearchClick(Sender: TObject);
begin
     CustInfo.SetKey ;
     CustInfo.IndexName := 'ByCompany';
     CustInfo.FieldByName ('Company').asString := txtSearch.Text ;
     CustInfo.GotoNearest ;
end;
0
Comment
Question by:Zoroaster
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1358810
The order should be like this instead:


         CustInfo.IndexName := 'ByCompany';
         CustInfo.SetKey ;
         CustInfo.FieldByName ('Company').asString := txtSearch.Text ;
         CustInfo.GotoNearest ;

Try also TTable.Locate...
0
 

Author Comment

by:Zoroaster
ID: 1358811
Yes, works fine. Sometimes small details can count...
Thanks, Matvey.
0
 

Author Comment

by:Zoroaster
ID: 1358812
Hey, fill in an answer. I cannot give you the points, because you wrote this as a comment.
0
 
LVL 3

Accepted Solution

by:
Matvey earned 80 total points
ID: 1358813
Hi, was out all day so I was slow with responding.
-Glad I could help

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question