Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 How do I do a locate on a non-indexed field?


How do I do a locate on a non-indexed field?   

    The following function can be added to your to your unit and called as follows: bool __fastcall Locate(const TTable *oTable, const TField *oField, const Char* SvALUE); Table is your table component, Table LName is TField you've added with the fields editor (double click on the table component) and 'Beman' is the name you want to find. // Locate will find SValue in a non-indexed table bool __fastcall Locate(const TTable *oTable, const TField *oField, const Char* SvALUE)

       {
          TBookMark bmPos;
          bool Locate, bFound;

    Locate = false; bFound = false;

    if (!oTable->Active) return;

    if (oTable->FieldDefs->IndexOf(oField->FieldName) < 0) return;

    bmPos = oTable->GetBookMark;

    oTable->DisableControls; oTable->First;

    while(!oTable->EOF) { if(oField->AsString == sValue) { Locate = true; bFound = true; break; } else oTable->Next; }

    if (!bFound) oTable->GotoBookMark(bmPos);

    oTable->FreeBookMark(bmPos); oTable->EnableControls; }

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use