Solved

Search for record with secondary index.

Posted on 1998-07-28
4
165 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now