Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting the name of a field?

Posted on 1997-10-12
3
147 Views
Last Modified: 2010-04-04
I am programmatically searching a dataset for a particular value using the locate function. what i need to know is how can i get the name of the field when the function successfully locates this value?(i use delphi 3)
0
Comment
Question by:naickers2
3 Comments
 

Accepted Solution

by:
crexes earned 50 total points
ID: 1347376
Hi...
The following example uses the "locate" - function and locates the value '10' in your table.
After that you can use the "fieldbyname" - procedure to get the value from the current position in the table.
I hope that this is what you wanted...
.
.
var SearchOptions : TLocateOptions;
    SearchKey, ValueThatIWant : integer;
.
.
  SearchKey := 10;
  TableName.Locate('FieldNameToSearchIn',SearchKey,                     SearchOptions);
  ValueThatIWant :=
  TableName.FieldByName('FieldNameThatYouWant').Value;
.
.
 


0
 

Author Comment

by:naickers2
ID: 1347377
This is not exactly what i wanted - forgive my vague question - this is the scenario - If i know the name of a table and need to see if it has a certain value in it and use the findnearest function which does not require any fieldnames to look in, if the search is successful, i need to extract the name of the field in which the value was found. I HAVE NO IDEA OR CLUE AS TO THE NAMES OF THE FIELDS IN THE TABLE. How do i do this?
0
 

Expert Comment

by:krisz
ID: 1347378
FindNearest searches only in the key fields, and search values specified in the correct order.

It won't search in the whole table.

You misunderstood something.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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