Question and Answer Database FAQ1929C.txt How do I do a locate on a non-indexed field? Category :Database Issues Platform :All Product :C++Builder 1.x Question: How do I do a locate on a non-indexed field? Answer: 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); Table1 is your table component, Table1LName 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; } 7/2/98 10:32:32 AM
Last Modified: 01-SEP-99