Solved

Search for record with secondary index.

Posted on 1998-07-28
4
167 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 20 total points
ID: 1358813
Hi, was out all day so I was slow with responding.
-Glad I could help

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
indy Tidtcpserver best  way to brodcast message to multiable clients 1 157
Delphi - replicating a form 8 74
Delphi selector screen 2 79
RESTRequest Parameter 4 31
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 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